Ejemplo n.º 1
0
        internal static bool CopyrightCodeExists(Build_DTO dto)
        {
            Copyright_BSO        bso    = new Copyright_BSO();
            Copyright_DTO_Create dtoCpr = bso.Read(dto.CprCode);

            return(dtoCpr.CprCode != null);
        }
Ejemplo n.º 2
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());
            }
        }