Exemplo n.º 1
0
        /// <summary>
        /// The get pfr statistic.
        /// </summary>
        /// <param name="batches">
        /// The batches.
        /// </param>
        /// <returns>
        /// The <see cref="PfrStatisticInfo"/> .
        /// </returns>
        private PfrStatisticInfo GetPfrStatistic(IEnumerable <Batch> batches)
        {
            var session = ObjectFactory.GetInstance <ISessionFactory>().GetCurrentSession();
            var result  = new PfrStatisticInfo();

            foreach (var batch in batches)
            {
                var message = batch.Messages.FirstOrDefault();
                if (message != null)
                {
                    var countQr = session.QueryOver <QueryResponse>().Where(x => x.Message.Id == message.Id).RowCount();

                    result.TotalRecordCount += countQr;

                    EmploymentHistory employmentHistory = null;
                    InsuredPerson     person            = null;
                    var foundRecordCount =
                        session.QueryOver <QueryResponse>()
                        .JoinAlias(x => x.EmploymentHistories, () => employmentHistory)
                        .Where(x => x.Message.Id == message.Id)
                        .RowCount();

                    var insuredRecordCount =
                        session.QueryOver <QueryResponse>()
                        .JoinAlias(x => x.EmploymentHistories, () => employmentHistory)
                        .JoinAlias(x => employmentHistory.InsuredPerson, () => person)
                        .Where(x => x.Message.Id == message.Id)
                        .And(x => person.Status.Id == StatusPerson.Active)
                        .RowCount();

                    var employedRecordCount =
                        session.QueryOver <QueryResponse>()
                        .JoinAlias(x => x.EmploymentHistories, () => employmentHistory)
                        .JoinAlias(x => employmentHistory.InsuredPerson, () => person)
                        .Where(x => x.Message.Id == message.Id)
                        .And(x => person.Status.Id == StatusPerson.Active)
                        .And(x => employmentHistory.Employment)
                        .RowCount();

                    result.NotFoundRecordCount += countQr - foundRecordCount;
                    result.InsuredRecordCount  += insuredRecordCount;
                    result.EmployedRecordCount += employedRecordCount;

                    switch (batch.Type.Id)
                    {
                    case ExchangeFileType.PfrData:
                        result.FoundByDataRecordCount += foundRecordCount;
                        break;

                    case ExchangeFileType.PfrSnils:
                        result.FoundBySnilsRecordCount += foundRecordCount;
                        break;
                    }
                }
            }

            return(result);
        }
Exemplo n.º 2
0
 private void FillStatisticInfo(PfrStatisticInfo info)
 {
     tbNotFoundRecordCount.Text     = info.NotFoundRecordCount.ToString();
     tbTotalRecordCount.Text        = info.TotalRecordCount.ToString();
     tbInsuredRecordCount.Text      = info.InsuredRecordCount.ToString();
     tbEmployedRecordCount.Text     = info.EmployedRecordCount.ToString();
     tbFoundByDataRecordCount.Text  = info.FoundByDataRecordCount.ToString();
     tbFoundBySnilsRecordCount.Text = info.FoundBySnilsRecordCount.ToString();
 }