示例#1
0
        public ActionResult CopyMultipleIndicators(string selectedIndicators, string selectedDomainId, string selectedProfileId)
        {
            var indicatorPropertiesList = selectedIndicators.Split(',').ToArray();

            foreach (var indicatorPropertiesString in indicatorPropertiesList)
            {
                var indicatorProperties = indicatorPropertiesString.Split('~');
                var groupId             = indicatorProperties[1];
                var indicatorId         = indicatorProperties[2];
                var areaTypeId          = indicatorProperties[3];
                var sexId = indicatorProperties[4];
                var ageId = indicatorProperties[5];

                var groupMetaData = _reader.GetGroupingMetadataList(new List <int> {
                    Convert.ToInt32(groupId)
                })[0];

                //Don't copy if identical indicator already exists in destination.
                if (!_profileRepository.IndicatorGroupingsExist(Convert.ToInt32(indicatorId), Convert.ToInt32(selectedDomainId), Convert.ToInt32(areaTypeId), Convert.ToInt32(ageId), Convert.ToInt32(sexId)))
                {
                    _profileRepository.CopyIndicatorToDomain(Convert.ToInt32(indicatorId), Convert.ToInt32(groupId), Convert.ToInt32(areaTypeId), Convert.ToInt32(sexId), Convert.ToInt32(ageId), Convert.ToInt32(selectedDomainId), Convert.ToInt32(areaTypeId), Convert.ToInt32(sexId), Convert.ToInt32(ageId));
                    _profileRepository.LogAuditChange("Indicator " + indicatorId + " copied from [" + groupMetaData.GroupName + " (Area: " + Convert.ToInt32(areaTypeId) + ")] Into " + "[" + _reader.GetGroupingMetadataList(new List <int> {
                        Convert.ToInt32(selectedDomainId)
                    })[0].GroupName + " (Area: " + Convert.ToInt32(areaTypeId) + ")]", Convert.ToInt32(indicatorId), null, _userName, DateTime.Now, CommonUtilities.AuditType.Copy.ToString());
                }
            }

            return(RedirectToAction("SortPageAndFilter", "ProfilesAndIndicators", new { ProfileKey = selectedProfileId }));
        }
示例#2
0
        public ActionResult ConfirmCopyIndicators(CopyIndicatorsModel cim, List <int> selectedDomainId,
                                                  int selectedAreaTypeId, string indicatorTransferDetails)
        {
            var groupId    = GetSelectedGroupIdUsingProfileKeyDomainAndAreaTypeId(cim.UrlKey, cim.DomainId, cim.AreaTypeId);
            var modelCount = 0;

            var indicatorSpecifierStrings = indicatorTransferDetails.Split(',').ToList();
            var indicatorSpecifiers       = IndicatorSpecifierParser.Parse(indicatorSpecifierStrings);

            foreach (var indicatorSpecifier in indicatorSpecifiers)
            {
                var indicatorId = indicatorSpecifier.IndicatorId;
                var sexId       = indicatorSpecifier.SexId;
                var ageId       = indicatorSpecifier.AgeId;

                // Don't copy if identical indicator (including age and sex Id) already exists in destination.
                if (!_dataAccess.IndicatorGroupingsExist(indicatorId, Convert.ToInt32(selectedDomainId[0]),
                                                         selectedAreaTypeId, Convert.ToInt32(ageId), Convert.ToInt32(sexId)))
                {
                    var currentIndicator = cim.IndicatorsToTransfer[modelCount];

                    _dataAccess.CopyIndicatorToDomain(indicatorId, groupId, cim.AreaTypeId,
                                                      currentIndicator.SexId, currentIndicator.AgeId,
                                                      Convert.ToInt32(selectedDomainId[0]), selectedAreaTypeId, sexId,
                                                      ageId);

                    _dataAccess.LogAuditChange("Indicator " + indicatorId + " copied from [" +
                                               cim.DomainName + " (Area: " + cim.AreaTypeId + ", SexId:" + currentIndicator.SexId +
                                               ", AgeId:" + currentIndicator.AgeId + " )] Into " +
                                               "[" + _reader.GetGroupingMetadataList(selectedDomainId)[0].GroupName +
                                               " (Area: " + selectedAreaTypeId + ", SexId:" + sexId + ", AgeId:" + ageId + " )]",
                                               indicatorId, null, _userName, DateTime.Now, CommonUtilities.AuditType.Copy.ToString());
                }
                modelCount++;
            }

            return(Redirect(Request.UrlReferrer.AbsoluteUri));
        }
        public ActionResult ConfirmCopyIndicators(CopyIndicatorsModel cim, List <int> selectedDomainId,
                                                  int selectedAreaTypeId, string indicatorTransferDetails, bool copyMetadataOption, string targetProfile)
        {
            var groupId    = GetSelectedGroupIdUsingProfileKeyDomainAndAreaTypeId(cim.UrlKey, cim.DomainId, cim.AreaTypeId);
            var modelCount = 0;

            var indicatorSpecifierStrings = indicatorTransferDetails.Split(',').ToList();
            var indicatorSpecifiers       = IndicatorSpecifierParser.Parse(indicatorSpecifierStrings);


            string targetProfileId = string.Empty;
            int    targetDomain = 0, targetAreaTypeId = 0;

            if (copyMetadataOption)
            {
                var targetProfileData = targetProfile.Split('~');
                targetProfileId  = targetProfileData[0];
                targetDomain     = Convert.ToInt32(targetProfileData[1]);
                targetAreaTypeId = Convert.ToInt32(targetProfileData[2]);
            }

            foreach (var indicatorSpecifier in indicatorSpecifiers)
            {
                var indicatorId = indicatorSpecifier.IndicatorId;
                var sexId       = indicatorSpecifier.SexId;
                var ageId       = indicatorSpecifier.AgeId;

                // Don't copy if identical indicator (including age and sex Id) already exists in destination.
                if (!_profileRepository.IndicatorGroupingsExist(indicatorId, Convert.ToInt32(selectedDomainId[0]),
                                                                selectedAreaTypeId, Convert.ToInt32(ageId), Convert.ToInt32(sexId)))
                {
                    var currentIndicator = cim.IndicatorsToTransfer[modelCount];

                    _profileRepository.CopyIndicatorToDomain(indicatorId, groupId, cim.AreaTypeId,
                                                             currentIndicator.SexId, currentIndicator.AgeId,
                                                             Convert.ToInt32(selectedDomainId[0]), selectedAreaTypeId, sexId,
                                                             ageId);

                    // Copy indicator meta data
                    if (copyMetadataOption)
                    {
                        var targetProfileDetails       = CommonUtilities.GetProfile(targetProfileId, targetDomain, targetAreaTypeId, _profileRepository);
                        var indicatorMetadataTextValue = _reader.GetMetadataTextValueForAnIndicatorById(indicatorId, cim.Profile.Id);
                        if (indicatorMetadataTextValue != null)
                        {
                            var indicatorMetadataTextValuesCopy = new IndicatorMetadataTextValue
                            {
                                IndicatorId     = indicatorId,
                                ProfileId       = targetProfileDetails.Id,
                                Name            = indicatorMetadataTextValue.Name,
                                NameLong        = indicatorMetadataTextValue.NameLong,
                                Definition      = indicatorMetadataTextValue.Definition,
                                Rationale       = indicatorMetadataTextValue.Rationale,
                                Policy          = indicatorMetadataTextValue.Policy,
                                DataSource      = indicatorMetadataTextValue.DataSource,
                                Producer        = indicatorMetadataTextValue.Producer,
                                IndMethod       = indicatorMetadataTextValue.IndMethod,
                                StandardPop     = indicatorMetadataTextValue.StandardPop,
                                CIMethod        = indicatorMetadataTextValue.CIMethod,
                                CountSource     = indicatorMetadataTextValue.CountSource,
                                CountDefinition = indicatorMetadataTextValue.CountDefinition,
                                DenomSource     = indicatorMetadataTextValue.DenomSource,
                                DenomDefinition = indicatorMetadataTextValue.DenomDefinition,
                                DiscControl     = indicatorMetadataTextValue.DiscControl,
                                Caveats         = indicatorMetadataTextValue.Caveats,
                                Copyright       = indicatorMetadataTextValue.Copyright,
                                Reuse           = indicatorMetadataTextValue.Reuse,
                                Links           = indicatorMetadataTextValue.Links,
                                RefNum          = indicatorMetadataTextValue.RefNum,
                                Notes           = indicatorMetadataTextValue.Notes,
                                Frequency       = indicatorMetadataTextValue.Frequency,
                                Rounding        = indicatorMetadataTextValue.Rounding,
                                DataQuality     = indicatorMetadataTextValue.DataQuality
                            };

                            _writer.NewIndicatorMetadataTextValue(indicatorMetadataTextValuesCopy);
                        }
                    }

                    _profileRepository.LogAuditChange("Indicator " + indicatorId + " copied from [" +
                                                      cim.DomainName + " (Area: " + cim.AreaTypeId + ", SexId:" + currentIndicator.SexId +
                                                      ", AgeId:" + currentIndicator.AgeId + " )] Into " +
                                                      "[" + _reader.GetGroupingMetadataList(selectedDomainId)[0].GroupName +
                                                      " (Area: " + selectedAreaTypeId + ", SexId:" + sexId + ", AgeId:" + ageId + " )]",
                                                      indicatorId, null, _userName, DateTime.Now, CommonUtilities.AuditType.Copy.ToString());
                }
                modelCount++;
            }

            return(Redirect(Request.UrlReferrer.AbsoluteUri));
        }