Example #1
0
 private OrgLinksNode(StatisticalUnit unit, IEnumerable <OrgLinksNode> children)
 {
     RegId         = unit.RegId;
     Name          = unit.Name;
     ParentOrgLink = unit.ParentOrgLink;
     OrgLinksNodes = children;
 }
Example #2
0
 public StatisticalUnitDuplicatesManager(StatisticalUnit enterpriseGroup, StatUnitAnalysisRules analysisRules,
                                         List <AnalysisDublicateResult> potentialDuplicates)
 {
     _checkingStatisticalUnit = enterpriseGroup;
     _analysisRules           = analysisRules;
     _potentialDuplicates     = potentialDuplicates;
 }
Example #3
0
        /// <summary>
        /// Method for updating stat properties. units
        /// </summary>
        /// <param name = "statUnit"> </param>
        /// <param name = "model"> </param>
        /// <returns> </returns>
        public static StatisticalUnit UpdateProperties(this StatisticalUnit statUnit, PersonStatUnitModel model)
        {
            statUnit.Name         = model.Name;
            statUnit.StatId       = model.StatId;
            statUnit.TelephoneNo  = model.TelephoneNo;
            statUnit.EmailAddress = model.EmailAddress;

            return(statUnit);
        }
Example #4
0
        private async Task PostProcessActivitiesUpload(StatisticalUnit unit)
        {
            if (!unit.Activities?.Any(activity => activity.Id == 0) == true)
            {
                return;
            }

            foreach (var activityUnit in unit.ActivitiesUnits)
            {
                if (activityUnit.Activity.Id != 0)
                {
                    continue;
                }
                var filled = await TryGetFilledActivityAsync(activityUnit.Activity);

                activityUnit.Activity = Mapper.Map(activityUnit.Activity, filled);
            }

            async Task <Activity> TryGetFilledActivityAsync(Activity activity)
            {
                var domainActivity = await _ctx.Activities
                                     .Include(a => a.ActivityCategory)
                                     .FirstOrDefaultAsync(a => a.ActivitiesUnits.Any(x => x.UnitId == unit.RegId) &&
                                                          a.ActivityCategory.Code == activity.ActivityCategory.Code);

                if (domainActivity != null)
                {
                    return(domainActivity);
                }

                activity.ActivityCategory =
                    await _ctx.ActivityCategories.FirstAsync(x => x.Code == activity.ActivityCategory.Code);

                return(activity);
            }
        }
Example #5
0
 /// <summary>
 /// Method for creating a model of an organizational link node
 /// </summary>
 /// <param name="unit">unit</param>
 /// <param name="children">children</param>
 /// <returns></returns>
 public static OrgLinksNode Create(StatisticalUnit unit, IEnumerable <OrgLinksNode> children)
 {
     return(unit != null ? new OrgLinksNode(unit, children) : throw new NotFoundException(nameof(Resource.OrgLinksNotFound)));
 }
Example #6
0
        private async Task PostProcessStatUnitsUpload(StatisticalUnit unit)
        {
            try
            {
                if (unit.Activities?.Any(activity => activity.Id == 0) == true)
                {
                    await unit.ActivitiesUnits
                    .ForEachAsync(async au =>
                    {
                        if (au.Activity.Id == 0)
                        {
                            au.Activity = await GetFilledActivity(au.Activity);
                        }
                    });
                }

                if (unit.Address?.Id == 0)
                {
                    unit.Address = await GetFilledAddress(unit.Address);
                }

                if (unit.PostalAddress?.Id == 0)
                {
                    unit.PostalAddress = await GetFilledAddress(unit.PostalAddress);
                }

                if (unit.ActualAddress?.Id == 0)
                {
                    unit.ActualAddress = await GetFilledAddress(unit.ActualAddress);
                }

                if (unit.ForeignParticipationCountriesUnits?.Any(fpcu => fpcu.Id == 0) == true)
                {
                    await unit.ForeignParticipationCountriesUnits.ForEachAsync(async fpcu =>
                    {
                        if (fpcu.Country.Id == 0)
                        {
                            var country    = await GetFilledCountry(fpcu.Country);
                            fpcu.Country   = country;
                            fpcu.CountryId = country.Id;
                            fpcu.UnitId    = unit.RegId;
                        }
                    });
                }

                if (unit.ForeignParticipation?.Id == 0)
                {
                    var fp = await GetFilledForeignParticipation(unit.ForeignParticipation);

                    unit.ForeignParticipation   = fp;
                    unit.ForeignParticipationId = fp.Id;
                }

                if (!string.IsNullOrEmpty(unit.LegalForm?.Name) || !string.IsNullOrEmpty(unit.LegalForm?.Code))
                {
                    unit.LegalForm = await GetFilledLegalForm(unit.LegalForm);

                    unit.LegalFormId = unit.LegalForm?.Id;
                }

                if (unit.LegalForm != null)
                {
                    unit.LegalFormId = unit.LegalForm?.Id;
                }

                if (unit.Persons?.Any(person => person.Id == 0) == true)
                {
                    await unit.PersonsUnits.ForEachAsync(async pu =>
                    {
                        if (pu.Person.Id == 0)
                        {
                            pu.Person = await GetFilledPerson(pu.Person);
                        }
                    });
                }

                if (unit.UnitType == StatUnitTypes.LocalUnit)
                {
                    var res = unit as LocalUnit;
                    if (res?.LegalUnitId != null && res.LegalUnitId != 0)
                    {
                        var legalUnit = await GetLegalUnitId(res.LegalUnitId.ToString());

                        res.LegalUnitId = legalUnit?.RegId;
                        unit            = res;
                    }
                }

                if (unit.UnitType == StatUnitTypes.LegalUnit)
                {
                    var res = unit as LegalUnit;
                    if (res?.EnterpriseUnitRegId != null && res.EnterpriseUnitRegId != 0)
                    {
                        var enterpriseUnit = await GetEnterpriseUnitRegId(res.EnterpriseUnitRegId.ToString());

                        res.EnterpriseUnitRegId = enterpriseUnit?.RegId;
                        unit = res;
                    }
                }

                if (unit.UnitType == StatUnitTypes.EnterpriseUnit)
                {
                    var res = unit as EnterpriseUnit;
                    if (res?.EntGroupId != null && res.EntGroupId != 0)
                    {
                        var enterpriseGroup = await GetEnterpriseGroupId(res.EntGroupId.ToString());

                        res.EntGroupId = enterpriseGroup?.RegId;
                        unit           = res;
                    }
                }

                if (!string.IsNullOrEmpty(unit.DataSourceClassification?.Name) || !string.IsNullOrEmpty(unit.DataSourceClassification?.Code))
                {
                    unit.DataSourceClassification = await GetFilledDataSourceClassification(unit.DataSourceClassification);

                    unit.DataSourceClassificationId = unit.DataSourceClassification?.Id;
                }

                if (!string.IsNullOrEmpty(unit.InstSectorCode?.Name) || !string.IsNullOrEmpty(unit.InstSectorCode?.Code))
                {
                    unit.InstSectorCode = await GetFilledSectorCode(unit.InstSectorCode);

                    unit.InstSectorCodeId = unit.InstSectorCode?.Id;
                }

                if (!string.IsNullOrEmpty(unit.Size?.Name))
                {
                    unit.Size = await GetFilledSize(unit.Size);

                    unit.SizeId = unit.Size?.Id;
                }

                if (!string.IsNullOrEmpty(unit.UnitStatus?.Name) || !string.IsNullOrEmpty(unit.UnitStatus?.Code))
                {
                    unit.UnitStatus = await GetFilledUnitStatus(unit.UnitStatus);

                    unit.UnitStatusId = unit.UnitStatus?.Id;
                }

                if (!string.IsNullOrEmpty(unit.ReorgType?.Name) || !string.IsNullOrEmpty(unit.ReorgType?.Code))
                {
                    unit.ReorgType = await GetFilledReorgType(unit.ReorgType);

                    unit.ReorgTypeId = unit.ReorgType?.Id;
                }

                if (!string.IsNullOrEmpty(unit.RegistrationReason?.Name) || !string.IsNullOrEmpty(unit.RegistrationReason?.Code))
                {
                    unit.RegistrationReason = await GetFilledRegistrationReason(unit.RegistrationReason);

                    unit.RegistrationReasonId = unit.RegistrationReason?.Id;
                }
            }
            catch (Exception ex)
            {
                ex.Data.Add("Postprocess exceptions at: ", unit);
                throw;
            }
        }
Example #7
0
 public async Task FillIncompleteDataOfStatUnit(StatisticalUnit unit, DataSourceUploadTypes uploadType)
 {
     await _postActionsMap[uploadType](unit);
 }
Example #8
0
 public StatisticalUnitMandatoryFieldsManager(StatisticalUnit unit, DbMandatoryFields mandatoryFields)
 {
     _statisticalUnit = unit;
     _mandatoryFields = mandatoryFields;
 }
Example #9
0
        private IEnumerable <Expression <Func <T, bool> > > GetStatisticalUnitPredicate(StatisticalUnit statisticalUnit)
        {
            var predicates = new List <Expression <Func <T, bool> > >
            {
                string.IsNullOrEmpty(statisticalUnit.ShortName)
                    ? False()
                    : GetPredicate(FieldEnum.ShortName, statisticalUnit.ShortName, OperationEnum.Equal),
                string.IsNullOrEmpty(statisticalUnit.TelephoneNo)
                    ? False()
                    : GetPredicate(FieldEnum.TelephoneNo, statisticalUnit.TelephoneNo, OperationEnum.Equal),
                string.IsNullOrEmpty(statisticalUnit.EmailAddress)
                    ? False()
                    : GetPredicate(FieldEnum.EmailAddress, statisticalUnit.EmailAddress, OperationEnum.Equal),
            };


            return(predicates);
        }