Ejemplo n.º 1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="dto"></param>
        /// <returns></returns>
        internal static bool StatisticsValueNotTheSameAsStatisticsLabel(Dimension_DTO dto)
        {
            var query = from vars in dto.Statistics
                        group vars by vars.Code into g
                        select new
            {
                Stat = g.First().Value
            };
            var result = from vars in query where vars.Stat.Equals(dto.StatisticLabel) select vars;

            return(result.Count() == 0);
        }
Ejemplo n.º 2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="dto"></param>
        /// <returns></returns>
        internal static bool ClassificationValueNotTheSameAsFrequencyValue(Dimension_DTO dto)
        {
            var query = from vars in dto.Classifications
                        group vars by vars.Code into g
                        select new
            {
                Clas = g.First().Value
            };
            var result = from vars in query where vars.Clas.Equals(dto.FrqValue) select vars;

            return(result.Count() == 0);
        }
Ejemplo n.º 3
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="parameters"></param>
        public BuildUpdate_DTO(dynamic parameters)
        {
            if (parameters.MtrInput != null)
            {
                this.MtrInput = Utility.DecodeBase64ToUTF8((string)parameters["MtrInput"]);
            }
            if (parameters.Data != null)
            {
                PxData = new PxData_DTO(parameters);
            }

            if (parameters.LngIsoCode != null)
            {
                LngIsoCode = parameters.LngIsoCode;
            }
            else
            {
                LngIsoCode = Configuration_BSO.GetCustomConfig(ConfigType.global, "language.iso.code");
            }
            Periods = new List <PeriodRecordDTO_Create>();

            if (parameters.MtrCode != null)
            {
                MtrCode = parameters.MtrCode;
            }
            if (parameters.CprCode != null)
            {
                CprCode = parameters.CprCode;
            }
            if (parameters.FrqCodeTimeval != null)
            {
                FrqCodeTimeval = parameters.FrqCodeTimeval;
            }
            if (parameters.FrqValueTimeval != null)
            {
                FrqValueTimeval = parameters.FrqValueTimeval;
            }
            if (parameters.MtrOfficialFlag != null)
            {
                MtrOfficialFlag = parameters.MtrOfficialFlag;
            }

            Format = new Format_DTO_Read();
            if (parameters.FrmType != null && parameters.FrmVersion != null)
            {
                Format.FrmType      = parameters.FrmType;
                Format.FrmVersion   = parameters.FrmVersion;
                Format.FrmDirection = Format_DTO_Read.FormatDirection.UPLOAD.ToString();
            }


            if (parameters.Signature != null)
            {
                this.Signature = parameters.Signature;
            }

            if (parameters.Labels != null)
            {
                this.Labels = parameters.Labels;
            }
            else
            {
                this.Labels = true;
            }


            if (parameters.Elimination != null)
            {
                Elimination = JsonConvert.DeserializeObject <Dictionary <string, string> >(parameters.Elimination.ToString());
            }

            if (parameters.Dimension != null)
            {
                Dimension = new List <Dimension_DTO>();
                foreach (var dim in parameters.Dimension)
                {
                    Dimension_DTO dimension = new Dimension_DTO();
                    if (dim.Frequency != null)
                    {
                        dimension.Frequency = new FrequencyRecordDTO_Create();
                        if (dim.Frequency.Period != null)
                        {
                            dimension.Frequency.Period = new List <Data.PeriodRecordDTO_Create>();
                            foreach (var per in dim.Frequency.Period)
                            {
                                PeriodRecordDTO_Create period = new PeriodRecordDTO_Create();
                                if (per.PrdCode != null)
                                {
                                    period.Code = per.PrdCode;
                                }
                                if (per.PrdValue != null)
                                {
                                    period.Value = per.PrdValue;
                                }
                                if (Periods.Where(x => x.Code.Equals(period.Code)).FirstOrDefault() == null)
                                {
                                    Periods.Add(period);
                                }
                                dimension.Frequency.Period.Add(period);
                            }
                        }
                        if (dim.Frequency.FrqValue != null)
                        {
                            dimension.Frequency.Value = dim.Frequency.FrqValue;
                        }
                    }
                    if (dim.Classification != null)
                    {
                        dimension.Classifications = new List <ClassificationRecordDTO_Create>();
                        foreach (var cls in dim.Classification)
                        {
                            ClassificationRecordDTO_Create classification = new ClassificationRecordDTO_Create();
                            if (cls.ClsCode != null)
                            {
                                classification.Code = cls.ClsCode;
                            }

                            dimension.Classifications.Add(classification);
                        }
                    }
                    if (dim.LngIsoCode != null)
                    {
                        dimension.LngIsoCode = dim.LngIsoCode;
                    }
                    if (dim.MtrTitle != null)
                    {
                        dimension.MtrTitle = dim.Dimension;
                    }
                    if (dim.FrqValue != null)
                    {
                        dimension.FrqValue = dim.FrqValue;
                    }
                    if (dim.MtrNote != null)
                    {
                        dimension.MtrNote = dim.MtrNote;
                    }
                    if (dim.StatisticLabel != null)
                    {
                        dimension.StatisticLabel = dim.StatisticLabel;
                    }
                    if (dim.MtrTitle != null)
                    {
                        dimension.MtrTitle = dim.MtrTitle;
                    }

                    Dimension.Add(dimension);
                }
            }

            if (parameters.Map != null)
            {
                Map = JsonConvert.DeserializeObject <Dictionary <string, string> >(parameters.Map.ToString());
            }
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Tests if two Dimension_DTO objects are equivalent, i.e. that the properties that are not language variant are the same and in the same order
        /// </summary>
        /// <param name="comp"></param>
        /// <returns></returns>
        internal bool IsEquivalent(Dimension_DTO comp)
        {
            //check that the Classification codes are the same and in the same order
            var thisCodeList  = String.Join(",", ((this.Classifications.Select(c => c.Code.ToString())).ToList <string>()).ToArray());
            var otherCodeList = String.Join(",", ((comp.Classifications.Select(c => c.Code.ToString())).ToList <string>()).ToArray());
            var thisPrdList   = String.Join(",", ((this.Frequency.Period.Select(c => c.Code.ToString())).ToList <string>()).ToArray());

            if (!thisCodeList.Equals(otherCodeList))
            {
                return(false);
            }

            //check that the Variables within the Classifications are the same and in the same order
            var thisVariableObjectList  = this.Classifications.Select(v => v.Variable);
            var otherVariableObjectList = comp.Classifications.Select(v => v.Variable);


            string thisVrbString = "";

            foreach (var vrb in thisVariableObjectList)
            {
                if (vrb != null)
                {
                    thisVrbString = thisVrbString + String.Join(",", ((vrb.Select(c => c.Code.ToString())).ToList <string>()).ToArray());
                }
            }
            string otherVrbString = "";

            foreach (var vrb in otherVariableObjectList)
            {
                if (vrb != null)
                {
                    otherVrbString = otherVrbString + String.Join(",", ((vrb.Select(c => c.Code.ToString())).ToList <string>()).ToArray());
                }
            }

            if (!thisVrbString.Equals(otherVrbString))
            {
                return(false);
            }

            //check that the Statistic codes are the same and in the same order
            var thisStatList = "";

            if (this.Statistics != null)
            {
                thisStatList = String.Join(",", ((this.Statistics.Select(c => c.Code.ToString())).ToList <string>()).ToArray());
            }

            var otherStatList = "";

            if (comp.Statistics != null)
            {
                otherStatList = String.Join(",", ((comp.Statistics.Select(c => c.Code.ToString())).ToList <string>()).ToArray());
            }

            if (!thisStatList.Equals(otherStatList))
            {
                return(false);
            }

            var otherPrdList = "";

            if (comp.Frequency.Period != null)
            {
                otherPrdList = String.Join(",", ((comp.Frequency.Period.Select(c => c.Code.ToString())).ToList <string>()).ToArray());
            }

            if (!thisPrdList.Equals(otherPrdList))
            {
                return(false);
            }

            return(true);
        }
Ejemplo n.º 5
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="parameters"></param>
        public Build_DTO(dynamic parameters)
        {
            if (parameters.MtrInput != null)
            {
                this.MtrInput = Utility.DecodeBase64ToUTF8((string)parameters["MtrInput"]);
            }

            this.LngIsoCode = Configuration_BSO.GetCustomConfig(ConfigType.global, "language.iso.code");


            if (parameters.MtrOfficialFlag != null)
            {
                this.MtrOfficialFlag = parameters.MtrOfficialFlag;
            }
            else
            {
                this.MtrOfficialFlag = Configuration_BSO.GetCustomConfig(ConfigType.global, "dataset.officialStatistics");
            }

            if (parameters.MtrCode != null)
            {
                this.MtrCode = parameters.MtrCode;
            }
            if (parameters.CprCode != null)
            {
                this.CprCode = parameters.CprCode;
            }
            if (parameters.FrqCode != null)
            {
                this.FrqCode = parameters.FrqCode;
            }
            if (parameters.FrqValue != null)
            {
                this.FrqValue = parameters.FrqValue;
            }
            Format = new Format_DTO_Read();
            if (parameters.FrmType != null && parameters.FrmVersion != null)
            {
                Format = new Format_DTO_Read
                {
                    FrmVersion   = parameters.FrmVersion,
                    FrmType      = parameters.FrmType,
                    FrmDirection = Format_DTO_Read.FormatDirection.UPLOAD.ToString()
                };
            }

            if (parameters.Elimination != null)
            {
                Elimination = JsonConvert.DeserializeObject <Dictionary <string, string> >(parameters.Elimination.ToString());
            }


            if (parameters.Dimension != null)
            {
                matrixDto = new Matrix_DTO();
                if (parameters.LngIsoCode != null)
                {
                    matrixDto.LngIsoCode = parameters.LngIsoCode;
                }
                else
                {
                    matrixDto.LngIsoCode = Configuration_BSO.GetCustomConfig(ConfigType.global, "language.iso.code");
                }

                if (parameters.MtrCode != null)
                {
                    matrixDto.MtrCode = parameters.MtrCode;
                }
                if (parameters.MtrOfficialFlag != null)
                {
                    matrixDto.MtrOfficialFlag = parameters.MtrOfficialFlag;
                }

                DimensionList = new List <Dimension_DTO>();

                foreach (var dim in parameters.Dimension)
                {
                    Dimension_DTO mlDto = new Dimension_DTO(dim);

                    if (dim.MtrTitle != null)
                    {
                        mlDto.Contents = dim.MtrTitle;
                        if (mlDto.Classifications != null)
                        {
                            mlDto.MtrTitle = mlDto.Contents + " (" + String.Join(", ", ((mlDto.Classifications.Select(c => c.Value.ToString())).ToList <string>()).ToArray()) + ')';
                        }
                        else
                        {
                            mlDto.MtrTitle = dim.MtrTitle;
                        }

                        if (mlDto.MtrTitle.Length > 256)
                        {
                            mlDto.MtrTitle = mlDto.MtrTitle.Substring(0, 256);
                        }
                    }

                    if (this.CprCode != null)
                    {
                        mlDto.CprCode = this.CprCode;
                        Copyright_BSO        cBso = new Copyright_BSO();
                        Copyright_DTO_Create cDTO = cBso.Read(this.CprCode);
                        mlDto.CprValue = cDTO.CprValue;
                    }
                    if (dim.CprValue != null)
                    {
                        mlDto.CprValue = dim.CprValue;
                    }

                    if (dim.Frequency != null)
                    {
                        mlDto.Frequency = new FrequencyRecordDTO_Create();

                        if (parameters.FrqCode != null)
                        {
                            mlDto.Frequency.Code = parameters.FrqCode;
                        }
                        if (dim.Frequency.FrqValue != null)
                        {
                            mlDto.Frequency.Value = dim.Frequency.FrqValue;
                        }

                        if (dim.Frequency.Period != null)
                        {
                            mlDto.Frequency.Period = new List <PeriodRecordDTO_Create>();
                            foreach (var per in dim.Frequency.Period)
                            {
                                PeriodRecordDTO_Create period = new Data.PeriodRecordDTO_Create();
                                if (per.PrdCode != null)
                                {
                                    period.Code = per.PrdCode;
                                }
                                if (per.PrdValue != null)
                                {
                                    period.Value = per.PrdValue;
                                }
                                mlDto.Frequency.Period.Add(period);
                            }
                        }
                    }

                    if (this.FrqCode != null)
                    {
                        mlDto.FrqCode = this.FrqCode;
                        //Get Frequency value
                        Frequency_BSO bso = new Frequency_BSO();
                        Frequency_DTO dto = new Frequency_DTO();
                        dto            = bso.Read(this.FrqCode);
                        mlDto.FrqValue = dto.FrqValue;
                    }

                    if (dim.FrqCode != null)
                    {
                        mlDto.FrqCode = dim.FrqCode;
                    }
                    if (dim.FrqValue != null)
                    {
                        mlDto.FrqValue = dim.FrqValue;
                    }

                    if (dim.LngIsoCode != null)
                    {
                        mlDto.LngIsoCode = dim.LngIsoCode;
                    }

                    if (dim.MtrTitle != null)
                    {
                        mlDto.MtrTitle = dim.MtrTitle;
                    }
                    if (dim.MtrNote != null)
                    {
                        mlDto.MtrNote = dim.MtrNote;
                    }


                    if (dim.Statistic != null)
                    {
                        mlDto.Statistics = new List <StatisticalRecordDTO_Create>();

                        foreach (var stat in dim.Statistic)
                        {
                            StatisticalRecordDTO_Create src = new StatisticalRecordDTO_Create(stat);

                            mlDto.Statistics.Add(src);
                        }
                    }


                    DimensionList.Add(mlDto);
                }
            }

            if (parameters.Map != null)
            {
                Map = JsonConvert.DeserializeObject <Dictionary <string, string> >(parameters.Map.ToString());
            }
        }