コード例 #1
0
        /// <summary>
        /// Build the code - description map for the specified component and add it to <see cref="_componentCodesDescriptionMap"/>.
        /// </summary>
        /// <param name="dim">
        /// The component
        /// </param>
        public void BuildCodeDescriptionMap(IComponent dim)
        {
            Dictionary <string, string> codeDescriptionMap;

            if (!this._componentCodesDescriptionMap.TryGetValue(dim.Id, out codeDescriptionMap))
            {
                codeDescriptionMap = new Dictionary <string, string>(StringComparer.Ordinal);
                this._componentCodesDescriptionMap.Add(dim.Id, codeDescriptionMap);
            }
            else
            {
                codeDescriptionMap.Clear();
            }

            ICodelistObject codelist = this.GetCachedCodelist(dim);
            string          lang     = this.CurrentCulture.TwoLetterISOLanguageName;

            foreach (ICode code in codelist.Items)
            {
                string desc = TextTypeHelper.GetText(code.Names, lang);
                if (string.IsNullOrEmpty(desc))
                {
                    desc = code.Id;
                }

                codeDescriptionMap.Add(code.Id, desc);
            }
        }
コード例 #2
0
        public Dictionary <string, CodemapObj> ParseCodelist(Dictionary <string, ICodelistObject> Codemap)
        {
            Dictionary <string, CodemapObj> drcodemap = new Dictionary <string, CodemapObj>();

            foreach (string conceptId in Codemap.Keys)
            {
                List <string> criteri = new List <string>();

                ICodelistObject codelist = Codemap[conceptId];
                CodemapObj      codemap  = new CodemapObj()
                {
                    title = TextTypeHelper.GetText(codelist.Names, this.CodemapObj.Configuration.Locale), codes = new Dictionary <string, CodeObj>()
                };

                foreach (ICode codeItem in codelist.Items.Where(ci => (criteri.Count > 0 ? criteri.Contains(ci.Id) : true)))
                {
                    codemap.codes.Add(
                        codeItem.Id.ToString(),
                        new CodeObj()
                    {
                        name   = TextTypeHelper.GetText(codeItem.Names, this.CodemapObj.Configuration.Locale),
                        parent = codeItem.ParentCode
                    });
                }

                codemap.codes = codemap.codes.OrderBy(c => c.Value.parent == null).ToDictionary(c => c.Key, c => c.Value);
                drcodemap.Add(conceptId, codemap);
            }
            return(drcodemap);
        }
コード例 #3
0
 /// <summary>
 /// Update the codelist cache with the specified codelist and component
 /// </summary>
 /// <param name="codelist">
 /// The codelist
 /// </param>
 /// <param name="component">
 /// The component
 /// </param>
 public void UpdateCodelistMap(ICodelistObject codelist, IComponent component)
 {
     this._codelistCache.Update(component, codelist);
     this._codeTreeMap[component] = new CodeTreeBuilder(codelist);
     if (component.HasCodedRepresentation() && !string.IsNullOrEmpty(component.Representation.Representation.MaintainableReference.MaintainableId))
     {
         this.BuildCodeDescriptionMap(component);
     }
 }
コード例 #4
0
		private ICode GetCode(ICodelistObject codelist, String codeId) {
			/* foreach */
			foreach (ICode currentCode  in  codelist.Items) {
				if (currentCode.Id.Equals(codeId)) {
					return currentCode;
				}
			}
			throw new ArgumentException("Code " + codeId
					+ " Not found in codelist : " + codelist.Urn);
		}
コード例 #5
0
        private List <string> AllPossibleValues(List <string> dimensions, IDataStructureObject kf, ISet <ICodelistObject> codelists)
        {
            if (NewLines.ContainsKey(string.Join("+", dimensions)))
            {
                return(NewLines[string.Join("+", dimensions)]);
            }
            Dictionary <string, string> allVals = new Dictionary <string, string>();
            List <string> BuilderSeries         = new List <string>();

            foreach (var dim in dimensions)
            {
                if (dim == kf.TimeDimension.Id)
                {
                    return(new List <string>());
                }
                IComponent component = kf.Components.FirstOrDefault(c => c.Id == dim);
                if (component == null || !component.HasCodedRepresentation() || string.IsNullOrEmpty(component.Representation.Representation.MaintainableReference.MaintainableId))
                {
                    return(new List <string>());
                }
                ICodelistObject codelist = codelists.First(c => c.Id == component.Representation.Representation.MaintainableReference.MaintainableId);
                if (codelist == null)
                {
                    continue;
                }

                List <string> InternalBuilderSeries = new List <string>();

                if (BuilderSeries.Count == 0)
                {
                    foreach (var code in codelist.Items)
                    {
                        InternalBuilderSeries.Add(code.Id);
                    }
                }
                else
                {
                    BuilderSeries.ForEach(bs =>
                    {
                        foreach (var code in codelist.Items)
                        {
                            InternalBuilderSeries.Add(bs + "+" + code.Id);
                        }
                    });
                }
                BuilderSeries = InternalBuilderSeries;
            }


            NewLines.Add(string.Join("+", dimensions), BuilderSeries);
            return(BuilderSeries);
        }
コード例 #6
0
        /// <summary>
        /// Initializes a new instance of the <see cref="CodeTreeBuilder"/> class.
        /// </summary>
        /// <param name="codelist">
        /// The codelist.
        /// </param>
        /// <exception cref="ArgumentNullException">
        /// codelist is null
        /// </exception>
        public CodeTreeBuilder(ICodelistObject codelist)
        {
            if (codelist == null)
            {
                throw new ArgumentNullException("codelist");
            }

            this._codeList     = codelist;
            this._idNodeMap    = new Dictionary <ICode, JsTreeNode>(codelist.Items.Count);
            this._rootNodes    = new List <JsTreeNode>(codelist.Items.Count);
            this._checkedNodes = new Dictionary <ICode, JsTreeNode>(codelist.Items.Count);
            this.BuildIdNodeMap();
        }
コード例 #7
0
        /// <summary>
        /// Update the codelist cache with the specified codelist and component
        /// </summary>
        /// <param name="codelist">
        /// The codelist
        /// </param>
        /// <param name="component">
        /// The component
        /// </param>
        public void UpdateCodelistMap(ICodelistObject codelist, IComponent component)
        {
            if (component.Id == KeyFamily.TimeDimension.Id)
            {
                this._codelistCache.Update(component, GetTimeCodeList(codelist));
                this._codeTreeMap[component] = new CodeTreeBuilder(GetTimeCodeList(codelist));
            }
            else
            {
                this._codelistCache.Update(component, codelist);
                this._codeTreeMap[component] = new CodeTreeBuilder(codelist);
            }


            if (component.HasCodedRepresentation() && !string.IsNullOrEmpty(component.Representation.Representation.MaintainableReference.MaintainableId))
            {
                this.BuildCodeDescriptionMap(component);
            }
        }
コード例 #8
0
        /// <summary>
        /// Get the maximum number of observations that can be retrieved given the specified criteria
        /// </summary>
        /// <param name="dataflow">
        /// The dataflow
        /// </param>
        /// <param name="criteria">
        /// The criteria includes a set of Member and MemberValue(s) for each dimension. Each member should have member values else they shouldn't be included. It can be null
        /// </param>
        /// <returns>
        /// The maximum number of observations or -1 if it can't be parsed or it is not available
        /// </returns>
        /// <exception cref="NsiClientException">
        /// NSI WS communication error or parsing error
        /// </exception>
        public int GetDataflowDataCount(IDataflowObject dataflow, IContentConstraintMutableObject criteria)
        {
            int count;
            List <IContentConstraintMutableObject> criterias = new List <IContentConstraintMutableObject>();

            if (criteria == null)
            {
                criteria = new ContentConstraintMutableCore();
            }

            criteria.Id = CustomCodelistConstants.CountCodeList;
            criteria.AddName("en", "name");
            criteria.AgencyId = "agency";
            criterias.Add(criteria);

            var codelistRef = new StructureReferenceImpl(SdmxStructureType.GetFromEnum(SdmxStructureEnumType.CodeList))
            {
                MaintainableId = CustomCodelistConstants.CountCodeList,
                AgencyId       = CustomCodelistConstants.Agency,
                Version        = CustomCodelistConstants.Version
            };
            string info = string.Format(CultureInfo.InvariantCulture, Resources.InfoCountFormat2, Utils.MakeKey(dataflow), Utils.MakeKey(codelistRef));

            try
            {
                ICodelistObject countCodelist = this.GetCodelist(dataflow, codelistRef, criterias, info, true);
                if (!CustomCodelistConstants.IsCountCodeList(countCodelist) ||
                    !int.TryParse(countCodelist.Items[0].Id, out count))
                {
                    Logger.WarnFormat(CultureInfo.InvariantCulture, Resources.ExceptionParsingCountCodelistFormat0, info);

                    throw new NsiClientException("Error parsing the count codelist for " + info);
                }
            }
            catch (NsiClientException ex)
            {
                Logger.Warn(ex.Message, ex);
                count = -1;
            }

            return(count);
        }
コード例 #9
0
        private string CalculateDominantFrequency(List <DataCriteria> Criterias, IDataStructureObject kf, ISet <ICodelistObject> codelists)
        {
            string DominantFreq = null;

            if (kf.FrequencyDimension.HasCodedRepresentation() && !string.IsNullOrEmpty(kf.FrequencyDimension.Representation.Representation.MaintainableReference.MaintainableId))
            {
                ICodelistObject codes = codelists.FirstOrDefault(c => c.Id == kf.FrequencyDimension.Representation.Representation.MaintainableReference.MaintainableId &&
                                                                 c.AgencyId == kf.FrequencyDimension.Representation.Representation.MaintainableReference.AgencyId &&
                                                                 c.Version == kf.FrequencyDimension.Representation.Representation.MaintainableReference.Version);
                if (codes.Items != null && codes.Items.Count > 1)
                {
                    List <string> allFreq = new List <string>();
                    codes.Items.ToList().ForEach(c => allFreq.Add(c.Id));

                    DataCriteria filter = Criterias.Find(cri => cri.component.Id == kf.FrequencyDimension.Id);
                    if (filter != null)
                    {
                        allFreq = filter.values;
                    }
                    if (allFreq.Count > 1)
                    {
                        if (allFreq.Contains("A"))
                        {
                            DominantFreq = "A";
                        }
                        if (allFreq.Contains("S"))
                        {
                            DominantFreq = "S";
                        }
                        if (allFreq.Contains("Q"))
                        {
                            DominantFreq = "Q";
                        }
                        if (allFreq.Contains("M"))
                        {
                            DominantFreq = "M";
                        }
                    }
                }
            }
            return(DominantFreq);
        }
コード例 #10
0
		public ReportedAttributeObjectBaseCore(
				IMetadataAttribute correspondingMA,
				IReportedAttribute builtFrom,
				IIdentifiableRetrievalManager retrievalManager) : base(builtFrom) {
                    this.reportedAttributes = new List<IReportedAttributeBase>();
			this.builtFrom = builtFrom;
			concept = retrievalManager.GetIdentifiableObject<IConceptObject>(
					correspondingMA.ConceptRef, typeof(IConceptObject));
			if (correspondingMA.HasCodedRepresentation()) {
                this.codelist = retrievalManager.GetIdentifiableObject<ICodelistObject>(
						correspondingMA.Representation.RepresentationRef,
						typeof(ICodelistObject));
			}
			if (builtFrom.ReportedAttributes != null) {
				/* foreach */
				foreach (IReportedAttribute reportedAttribute  in  builtFrom
						.ReportedAttributes) {
					IMetadataAttribute metadataAttribute = GetMetadataAttributeForRepotedAttribtue(
							reportedAttribute, correspondingMA.MetadataAttributes);
					reportedAttributes.Add(new ReportedAttributeObjectBaseCore(metadataAttribute, reportedAttribute, retrievalManager));
				}
			}
		}
コード例 #11
0
ファイル: IOUtils.cs プロジェクト: alcardac/SDMX_ART_REPO
        public void SaveDotSTATCodelistFile(ICodelistObject codelist)
        {
            CodelistExporter _codeExp = new CodelistExporter(codelist.Id, codelist);
            List<ISTAT.IO.Utility.FileGeneric> files = new List<ISTAT.IO.Utility.FileGeneric>();
            List<ContactRef> contacs = GetConfigContact();
            string ExportFileName;

            ExportFileName = "DotStatExport-" + codelist.Id + "_" + codelist.AgencyId + "_" + codelist.Version;

            _codeExp.CreateData(contacs);

            System.Xml.XmlDocument xDoc_code = _codeExp.XMLDoc;
            MemoryStream xmlStream_code = new MemoryStream();
            xDoc_code.Save(xmlStream_code);
            xmlStream_code.Flush();
            xmlStream_code.Position = 0;
            ISTAT.IO.Utility.FileGeneric file_code = new ISTAT.IO.Utility.FileGeneric();
            file_code.filename = _codeExp.Code.ToString() + ".xml";
            file_code.stream = xmlStream_code;
            files.Add(file_code);

            Stream streamCSV = CSVWriter.CreateStream(_codeExp.DataView);
            ISTAT.IO.Utility.FileGeneric file_csv = new ISTAT.IO.Utility.FileGeneric();
            file_csv.filename = _codeExp.DataFilename;
            file_csv.stream = streamCSV;
            files.Add(file_csv);

            string fileZip = System.Web.HttpContext.Current.Server.MapPath("OutputFiles" + "\\" + ExportFileName + ".zip");

            System.IO.File.Delete(fileZip);
            Ionic.Utils.Zip.ZipFile zip = new Ionic.Utils.Zip.ZipFile(fileZip);
            foreach (ISTAT.IO.Utility.FileGeneric file in files)
                zip.AddFileStream(file.filename, string.Empty, file.stream);
            zip.Save();

            SendAttachment(fileZip, ExportFileName + ".zip");
        }
コード例 #12
0
        ///////////////////////////////////////////////////////////////////////////////////////////////////
        ////////////BUILD FROM V1 SCHEMA                 //////////////////////////////////////////////////
        ///////////////////////////////////////////////////////////////////////////////////////////////////

        /// <summary>
        /// Initializes a new instance of the <see cref="CodeCore"/> class.
        /// </summary>
        /// <param name="parent">
        /// The parent. 
        /// </param>
        /// <param name="code">
        /// The sdmxObject. 
        /// </param>
        public CodeCore(ICodelistObject parent, Org.Sdmx.Resources.SdmxMl.Schemas.V10.structure.CodeType code)
            : base(code, _codeType, code.value, null, code.Description, null, code.Annotations, parent)
        {
        }
コード例 #13
0
        ///////////////////////////////////////////////////////////////////////////////////////////////////
        ////////////BUILD FROM READER                    //////////////////////////////////////////////////
        ///////////////////////////////////////////////////////////////////////////////////////////////////    
        // public CodeCore(ICodelistObject parent, SdmxReader reader) {
        // super(validateRootElement(reader), reader, parent);
        // if(reader.moveToElement("Parent", "Code")) {
        // reader.moveNextElement();  //Move to the Ref Node
        // if(!reader.getCurrentElement().equals("Ref")) {
        // throw new SdmxSemmanticException("Expecting 'Ref' element after 'Parent' element for Code");
        // }
        // this.parentCode = reader.getAttributeValue("id", true);
        // } 
        // }

        // private static SdmxStructureType validateRootElement(SdmxReader reader) {
        // if(!reader.getCurrentElement().equals("Code")) {
        // throw new SdmxSemmanticException("Can not construct code - expecting 'Code' Element in SDMX, actual element:" + reader.getCurrentElementValue());
        // }
        // return SdmxStructureType.GetFromEnum(SdmxStructureEnumType.CODE);
        // }

        ///////////////////////////////////////////////////////////////////////////////////////////////////
        ////////////BUILD FROM V2.1 SCHEMA                 //////////////////////////////////////////////////
        ///////////////////////////////////////////////////////////////////////////////////////////////////

        /// <summary>
        /// Initializes a new instance of the <see cref="CodeCore"/> class.
        /// </summary>
        /// <param name="parent">
        /// The parent. 
        /// </param>
        /// <param name="code">
        /// The sdmxObject. 
        /// </param>
        public CodeCore(ICodelistObject parent, CodeType code)
            : base(code, _codeType, parent)
        {
            var parentItem = code.GetTypedParent<LocalCodeReferenceType>();
            this.parentCode = (parentItem != null) ? parentItem.GetTypedRef<LocalCodeRefType>().id : null;
        }
コード例 #14
0
        ///////////////////////////////////////////////////////////////////////////////////////////////////
        ////////////BUILD FROM V2 SCHEMA                 //////////////////////////////////////////////////
        ///////////////////////////////////////////////////////////////////////////////////////////////////

        /// <summary>
        /// Initializes a new instance of the <see cref="CodeCore"/> class.
        /// </summary>
        /// <param name="parent">
        /// The parent. 
        /// </param>
        /// <param name="code">
        /// The sdmxObject. 
        /// </param>
        public CodeCore(ICodelistObject parent, Org.Sdmx.Resources.SdmxMl.Schemas.V20.structure.CodeType code)
            : base(code, _codeType, code.value, null, code.Description, null, code.Annotations, parent)
        {
            // In SDMX 2.0 it is perfectly valid for the XML to state a code has a parentCode which is blank. e.g.:
            //    <str:Code value="aCode" parentCode="">
            // This can cause issues when manipulating the beans, so police the input by not setting the 
            // parentCode if it is an empty string.
            this.parentCode = string.IsNullOrWhiteSpace(code.parentCode) ? null : code.parentCode;
        }
コード例 #15
0
/*
 *      /// <summary>
 *      /// Check if the specified <c>CodelistRefBean</c> is for the special COUNT request
 *      /// </summary>
 *      /// <param name="codelistRef">
 *      /// The <c>CodelistRefBean</c> object. It should have Id and Agency set. Version is ignored.
 *      /// </param>
 *      /// <returns>
 *      /// True if the  <c>CodelistRefBean</c> ID and Agency matches the custom <see cref="CountCodeList"/> and <see cref="Agency"/>. Else false
 *      /// </returns>
 *      public static bool IsCountRequest(CodelistRefBean codelistRef)
 *      {
 *          return CountCodeList.Equals(codelistRef.Id, StringComparison.InvariantCultureIgnoreCase)
 *                 && Agency.Equals(codelistRef.AgencyID, StringComparison.InvariantCultureIgnoreCase);
 *      }
 *
 */

        /// <summary>
        /// Check if the specified <c>CodeListBean</c> is the special COUNT codelist
        /// </summary>
        /// <param name="codelist">
        /// The <c>CodeListBean</c> object. It should have Id and Agency set. Version is ignored.
        /// </param>
        /// <returns>
        /// True if the  <c>CodeListBean</c> ID and Agency matches the custom <see cref="CountCodeList"/> and <see cref="Agency"/>. Else false
        /// </returns>
        public static bool IsCountCodeList(ICodelistObject codelist)
        {
            return(CountCodeList.Equals(codelist.Id, StringComparison.OrdinalIgnoreCase) &&
                   Agency.Equals(codelist.AgencyId, StringComparison.OrdinalIgnoreCase) &&
                   codelist.Items.Count == 1);
        }
コード例 #16
0
        private ICodelistObject GetTimeCodeList(ISdmxObjects sdmxObjects, ICodelistObject FreqCodelist, IDataStructureObject kf)
        {
            if (this.SessionObj.CodelistConstrained != null && this.SessionObj.CodelistConstrained.ContainsKey(Utils.MakeKey(kf))
                && this.SessionObj.CodelistConstrained[Utils.MakeKey(kf)].ContainsKey(kf.TimeDimension.Id))
            {
                ICodelistObject codes = this.SessionObj.CodelistConstrained[Utils.MakeKey(kf)][kf.TimeDimension.Id];
                if (codes != null)
                    return codes;
            }
            var codelist = (from c in sdmxObjects.Codelists where c.Id == kf.TimeDimension.Id select c).FirstOrDefault();
            ICodelistObject CL_TIME_MA = codelist;
            if (CL_TIME_MA == null
                || CL_TIME_MA.Items == null
                || CL_TIME_MA.Items.Count != 2)
                return CL_TIME_MA;

            //string format_time = (CL_TIME_MA.Items[0].Id.Contains("-")) ? "yyyy-MM-dd" : "yyyy";
            string time_min_normal = CL_TIME_MA.Items[0].Id;
            string time_max_normal = CL_TIME_MA.Items[1].Id;

            string FrequencyDominant = "A";
            if (FreqCodelist.Items.Count(c => c.Id.ToUpper() == "S") > 0) FrequencyDominant = "S";
            if (FreqCodelist.Items.Count(c => c.Id.ToUpper() == "Q") > 0) FrequencyDominant = "Q";
            if (FreqCodelist.Items.Count(c => c.Id.ToUpper() == "M") > 0) FrequencyDominant = "M";

            if (!CL_TIME_MA.Items[0].Id.Contains("-"))
            {
                time_min_normal = string.Format("{0}-{1}-{2}", CL_TIME_MA.Items[0].Id, "01", "01");
                time_max_normal = string.Format("{0}-{1}-{2}", CL_TIME_MA.Items[1].Id, "01", "01");
            }
            else
            {
                var time_p_c = CL_TIME_MA.Items[0].Id.Split('-');
                if (time_p_c.Length == 2)
                {
                    int mul =
                        (FrequencyDominant == "M") ? 1 :
                        (FrequencyDominant == "Q") ? 3 :
                        (FrequencyDominant == "S") ? 6 : 0;

                    int t_fix = (int.Parse(time_p_c[1].Substring(1))) * mul;
                    time_min_normal = string.Format("{0}-{1}-{2}", time_p_c[0], (t_fix > 9) ? t_fix.ToString() : "0" + t_fix.ToString(), "01");
                    time_p_c = CL_TIME_MA.Items[1].Id.Split('-');
                    t_fix = (int.Parse(time_p_c[1].Substring(1))) * mul;
                    time_max_normal = string.Format("{0}-{1}-{2}", time_p_c[0], (t_fix > 9) ? t_fix.ToString() : "0" + t_fix.ToString(), "01");
                }
                if (CL_TIME_MA.Items[0].Id.Contains("S"))
                {
                    var time_p = CL_TIME_MA.Items[0].Id.Split('-');
                    int t_fix = (int.Parse(time_p[1].Substring(1))) * 6;
                    time_min_normal = string.Format("{0}-{1}-{2}", time_p[0], (t_fix > 9) ? t_fix.ToString() : "0" + t_fix.ToString(), "01");

                    time_p = CL_TIME_MA.Items[1].Id.Split('-');
                    t_fix = (int.Parse(time_p[1].Substring(1))) * 6;
                    time_max_normal = string.Format("{0}-{1}-{2}", time_p[0], (t_fix > 9) ? t_fix.ToString() : "0" + t_fix.ToString(), "01");
                }
                if (CL_TIME_MA.Items[0].Id.Contains("Q"))
                {
                    var time_p = CL_TIME_MA.Items[0].Id.Split('-');
                    int t_fix = ((int.Parse(time_p[1].Substring(1))) * 3);
                    time_min_normal = string.Format("{0}-{1}-{2}", time_p[0], (t_fix > 9) ? t_fix.ToString() : "0" + t_fix.ToString(), "01");

                    time_p = CL_TIME_MA.Items[1].Id.Split('-');
                    t_fix = ((int.Parse(time_p[1].Substring(1))) * 3);
                    time_max_normal = string.Format("{0}-{1}-{2}", time_p[0], (t_fix > 9) ? t_fix.ToString() : "0" + t_fix.ToString(), "01");
                }
                if (CL_TIME_MA.Items[0].Id.Contains("M"))
                {
                    var time_p = CL_TIME_MA.Items[0].Id.Split('-');
                    int t_fix = (int.Parse(time_p[1].Substring(1))) * 1;
                    time_min_normal = string.Format("{0}-{1}-{2}", time_p[0], (t_fix > 9) ? t_fix.ToString() : "0" + t_fix.ToString(), "01");

                    time_p = CL_TIME_MA.Items[1].Id.Split('-');
                    t_fix = (int.Parse(time_p[1].Substring(1))) * 1;
                    time_max_normal = string.Format("{0}-{1}-{2}", time_p[0], (t_fix > 9) ? t_fix.ToString() : "0" + t_fix.ToString(), "01");
                }
            }

            DateTime MinDate = DateTime.ParseExact(time_min_normal, "yyyy-MM-dd", CultureInfo.CurrentCulture, DateTimeStyles.None);
            DateTime MaxDate = DateTime.ParseExact(time_max_normal, "yyyy-MM-dd", CultureInfo.CurrentCulture, DateTimeStyles.None);

            ICodelistMutableObject CL_TIME = new CodelistMutableCore();
            CL_TIME.Id = CL_TIME_MA.Id;
            CL_TIME.AgencyId = CL_TIME_MA.AgencyId;
            CL_TIME.Version = CL_TIME_MA.Version;

            CL_TIME_MA.Names.ToList().ForEach(n => CL_TIME.AddName(n.Locale, n.Value));

            DateTime ActualDate = MinDate;
            switch (FrequencyDominant)
            {
                case "A":
                    #region Aggiungo gli Annual
                    while (ActualDate.CompareTo(MaxDate) < 0)
                    {
                        ICodeMutableObject code = new CodeMutableCore();
                        code.Id = ActualDate.Year.ToString();
                        code.AddName("en", code.Id);
                        CL_TIME.AddItem(code);

                        ActualDate = ActualDate.AddYears(1);
                    }
                    #endregion
                    break;
                case "S":
                    #region Aggiungo gli Semestrali
                    while (ActualDate.CompareTo(MaxDate) < 0)
                    {
                        ICodeMutableObject code = new CodeMutableCore();
                        code.Id = ActualDate.Year.ToString() + "-S" + (ActualDate.Month < 6 ? "1" : "2");
                        code.AddName("en", code.Id);
                        CL_TIME.AddItem(code);

                        ActualDate = ActualDate.AddMonths(6);
                    }
                    #endregion
                    break;
                case "Q":
                    #region Aggiungo i Quartely
                    while (ActualDate.CompareTo(MaxDate) < 0)
                    {
                        ICodeMutableObject code = new CodeMutableCore();
                        code.Id = ActualDate.Year.ToString() + "-Q" + ((ActualDate.Month - 1) / 3 + 1).ToString();
                        code.AddName("en", code.Id);
                        CL_TIME.AddItem(code);

                        ActualDate = ActualDate.AddMonths(3);
                    }
                    #endregion
                    break;
                case "M":
                    #region Aggiungo i Mensili
                    while (ActualDate.CompareTo(MaxDate) < 0)
                    {
                        ICodeMutableObject code = new CodeMutableCore();
                        code.Id = ActualDate.ToString("yyyy-MM");
                        code.AddName("en", code.Id);
                        CL_TIME.AddItem(code);

                        ActualDate = ActualDate.AddMonths(1);
                    }
                    #endregion
                    break;
                default:
                    break;
            }

            return CL_TIME.ImmutableInstance;
        }
コード例 #17
0
        private void SetGeneralTab(ICodelistObject cl)
        {
            txt_id.Text = cl.Id;
            txtAgenciesReadOnly.Text = cl.AgencyId;
            txt_version.Text = cl.Version;
            chk_isFinal.Checked = cl.IsFinal.IsTrue;

            FileDownload31.ucID = cl.Id;
            FileDownload31.ucAgency = cl.AgencyId;
            FileDownload31.ucVersion = cl.Version;
            FileDownload31.ucArtefactType = "CodeList";

            txt_uri.Text = (cl.Uri != null) ? cl.Uri.AbsoluteUri : string.Empty;
            txt_urn.Text = (cl.Urn != null) ? cl.Urn.AbsoluteUri : string.Empty;
            txt_valid_from.Text = (cl.StartDate != null) ? string.Format("{0}/{1}/{2}", cl.StartDate.Date.Value.Day.ToString(), cl.StartDate.Date.Value.Month.ToString(), cl.StartDate.Date.Value.Year.ToString()) : string.Empty;
            txt_valid_to.Text = (cl.EndDate != null) ? string.Format("{0}/{1}/{2}", cl.EndDate.Date.Value.Day.ToString(), cl.EndDate.Date.Value.Month.ToString(), cl.EndDate.Date.Value.Year.ToString()) : string.Empty;

            txt_name_locale.Text = _localizedUtils.GetNameableName(cl);
            txt_description_locale.Text = _localizedUtils.GetNameableDescription(cl);

            // Svuoto le griglie
            //===========================================
            if (AddTextName.TextObjectList != null && AddTextName.TextObjectList.Count != 0)
            {
                AddTextName.ClearTextObjectList();
            }
            if (AddTextDescription.TextObjectList != null && AddTextDescription.TextObjectList.Count != 0)
            {
                AddTextDescription.ClearTextObjectList();
            }
            if (AnnotationGeneralControl.AnnotationObjectList != null && AnnotationGeneralControl.AnnotationObjectList.Count != 0)
            {
                AnnotationGeneralControl.ClearAnnotationsSession();
            }

            txt_id.Enabled = false;
            txt_version.Enabled = false;
            cmb_agencies.Enabled = false;

            if (_action == Action.VIEW || cl.IsFinal.IsTrue)
            {
                AddTextName.Visible = false;
                txt_all_names.Visible = true;
                txt_all_names.Text = _localizedUtils.GetNameableName(cl);

                AddTextDescription.Visible = false;
                txt_all_description.Visible = true;
                txt_all_description.Text = _localizedUtils.GetNameableDescription(cl);
                Utils.ResetBeforeUnload();
            }
            else
            {
                AspConfirmationExit = "true";

                AddTextName.Visible = true;
                AddTextDescription.Visible = true;
                txt_all_description.Visible = false;
                txt_all_names.Visible = false;

                AddTextName.InitTextObjectList = cl.Names;
                AddTextDescription.InitTextObjectList = cl.Descriptions;
            }

            if ( _action != Action.VIEW )
            {
                DuplicateArtefact1.Visible = true;
            }

            AnnotationGeneralControl.AddText_ucOpenTabName = AnnotationGeneralControl.ClientID;
            AnnotationGeneralControl.AnnotationObjectList = cl.MutableInstance.Annotations;
            AnnotationGeneralControl.EditMode = (cl.IsFinal.IsTrue || _action == Action.VIEW) ? false :true;
            AnnotationGeneralControl.OwnerAgency =  txtAgenciesReadOnly.Text;
            ctr_annotation_update.EditMode = (cl.IsFinal.IsTrue || _action == Action.VIEW) ? false : true;

            if (_action == Action.VIEW || cl.IsFinal.IsTrue)
            {
                txt_valid_from.Enabled = false;
                txt_valid_to.Enabled = false;
                txt_name_locale.Enabled = false;
                txt_description_locale.Enabled = false;
                txt_uri.Enabled = false;
                chk_isFinal.Enabled = false;
            }
            else
            {
                txt_valid_from.Enabled = true;
                txt_valid_to.Enabled = true;
                txt_name_locale.Enabled = true;
                txt_description_locale.Enabled = true;
                txt_uri.Enabled = true;
                chk_isFinal.Enabled = true;
            }

            //===========================================

            if ( _action == Action.INSERT )
            {
                cmb_agencies.Visible = true;
                txtAgenciesReadOnly.Visible = false;
            }
            else
            {
                cmb_agencies.Visible = false;
                txtAgenciesReadOnly.Visible = true;
            }

            SetCodeDetailPanel(cl);
        }
コード例 #18
0
        public SessionImplObject GetDataChart(SessionQuery sessionQuery)
        {
            try
            {
                // Init session objects
                if (this.SessionObj == null)
                {
                    this.SessionObj            = new SessionImplObject();
                    this.SessionObj.SdmxObject = new SdmxObjectsImpl();
                }

                JavaScriptSerializer ser = new JavaScriptSerializer();
                ser.MaxJsonLength = int.MaxValue;

                #region +++ Caching +++
                ConnectionStringSettings connectionStringSetting;
                CacheWidget cache          = null;
                bool        UseWidgetCache = (WebClientSettings.Instance != null) ? WebClientSettings.Instance.UseWidgetCache : false;
                if (UseWidgetCache)
                {
                    connectionStringSetting = ConfigurationManager.ConnectionStrings["ISTATWebClientConnection"];
                    cache = new CacheWidget(connectionStringSetting.ConnectionString);
                }
                if (ChartObj.WidgetId > 0 && UseWidgetCache)
                {
                    SavedWidget widget = cache.GetWidget(ChartObj.WidgetId, ChartObj.Configuration.Locale);
                    if (widget != null && !String.IsNullOrEmpty(widget.widgetData))
                    {
                        this.SessionObj.SavedChart = widget.widgetData;
                        return(this.SessionObj);
                    }
                }
                #endregion

                if (BDO == null || GetSDMXObject == null)
                {
                    throw new Exception(Messages.label_error_network);
                }

                codemapWidget = new CodemapWidget(
                    new GetCodemapObject()
                {
                    PreviusCostraint = this.ChartObj.Criteria,
                    Configuration    = this.ChartObj.Configuration,
                    Dataflow         = this.ChartObj.Dataflow
                },
                    this.SessionObj, sessionQuery);


                //ISdmxObjects structure = codemapWidget.GetDsd();
                //IDataflowObject df = structure.Dataflows.FirstOrDefault();
                //IDataStructureObject kf = structure.DataStructures.First();
                ISdmxObjects structure = sessionQuery.Structure;
                //IDataflowObject df = structure.Dataflows.First();
                IDataflowObject df = sessionQuery.Dataflow;
                //IDataStructureObject kf = structure.DataStructures.First();
                IDataStructureObject kf = sessionQuery.KeyFamily;

                if (kf == null)
                {
                    throw new InvalidOperationException("DSD is not set");
                }
                if (df == null)
                {
                    throw new InvalidOperationException("Dataflow is not set");
                }

                Dictionary <string, ICodelistObject> ConceptCodelists = codemapWidget.GetCodelistMap(df, kf, false);
                ComponentCodeDescriptionDictionary   codemap          = new ComponentCodeDescriptionDictionary();
                foreach (string ConceptId in ConceptCodelists.Keys)
                {
                    ICodelistObject             codelist = ConceptCodelists[ConceptId];
                    Dictionary <string, string> codes    = new Dictionary <string, string>();

                    foreach (ICode codeItem in codelist.Items)
                    {
                        codes.Add(codeItem.Id, TextTypeHelper.GetText(codeItem.Names, this.ChartObj.Configuration.Locale));
                    }
                    codemap.Add(ConceptId, codes);

                    //var useFix20 = (ConfigurationManager.AppSettings["UseFix20Criteria"].ToString().ToLower() == "true");
                    //fabio prova
                    var useFix20 = (ConfigurationManager.AppSettings["UseFix20Criteria"].ToString().ToLower() == "false");
                    if (useFix20)
                    {
                        if (!(codelist.Items.Count > 1))
                        {
                            this.ChartObj.Criteria.Remove(ConceptId);
                        }
                    }
                }

                this.SessionObj.MergeObject(codemapWidget.SessionObj);

                #region Gestione last period
                int num1;
                if (this.ChartObj.Criteria.ContainsKey(kf.TimeDimension.Id) &&
                    this.ChartObj.Criteria[kf.TimeDimension.Id].Count == 1 &&
                    int.TryParse(this.ChartObj.Criteria[kf.TimeDimension.Id].First(), out num1)
                    )
                {
                    int offsetTime = int.Parse(this.ChartObj.Criteria[kf.TimeDimension.Id].First());
                    var codMap     = codemap;
                    int lengthTime = codMap[kf.TimeDimension.Id].Count;

                    if ((lengthTime - offsetTime) >= 0)
                    {
                        var           codes         = codMap[kf.TimeDimension.Id].Reverse().Take(offsetTime);
                        List <string> _criteriaTime = (from c in codes select c.Key).ToList <string>();

                        this.ChartObj.Criteria[kf.TimeDimension.Id] = new List <string>();
                        this.ChartObj.Criteria[kf.TimeDimension.Id].Add(_criteriaTime.Last());
                        this.ChartObj.Criteria[kf.TimeDimension.Id].Add(_criteriaTime.First());
                    }
                    else
                    {
                        this.ChartObj.Criteria[kf.TimeDimension.Id] = new List <string>();
                        this.ChartObj.Criteria[kf.TimeDimension.Id].Add(codemap[kf.TimeDimension.Id].First().Key);
                        this.ChartObj.Criteria[kf.TimeDimension.Id].Add(codemap[kf.TimeDimension.Id].Last().Key);
                    }
                }

                #endregion

                List <DataCriteria> Criterias = BDO.InitCriteria(kf, this.ChartObj.Criteria);
                //List<DataCriteria> Criterias = sessionQuery.GetCriteria();
                Dictionary <string, List <DataChacheObject> > DataCache = SessionObj.DataCache;


                //aggiunta da fabio
                //IDataSetStore store = BDO.GetDataset(df, kf, Criterias, ref DataCache, false, sessionQuery);

                IDataSetStore store = sessionQuery._store;
                store.SetCriteria(Criterias);

                /*
                 * IDataSetStore store;
                 * if (sessionQuery._store != null)
                 * { store = sessionQuery._store; }
                 * else
                 * {
                 *  //store = BDO.GetDataset(df, kf, Criterias, ref DataCache, _useAttr);
                 *  store = BDO.GetDataset(df, kf, Criterias, ref DataCache, false, sessionQuery);
                 *  sessionQuery._store = store;
                 * }
                 */
                //fine nuovo



                //string DBFileName = null;
                //IDataSetStore store = BDO.FindDataCache(df, kf, Criterias, ref DataCache, false, out DBFileName);
                //if (store == null) store = BDO.GetDataset(df, kf, Criterias, ref DataCache);
                //if (store == null) store = BDO.GetDataset(df, kf, Criterias, ref DataCache, false);



                //da vedere se eliminare aggiunta fabio per svuotare datacache
                SessionObj.DataCache = null;


                SessionObj.DataCache = DataCache;

                DataObjectForStreaming DataStream = new DataObjectForStreaming()
                {
                    store     = store,
                    Criterias = Criterias,
                    structure = structure,
                    codemap   = codemap
                };

                ChartResponseObject ChartResponse = new ChartResponseObject();
                ChartResponse.series_title = TextTypeHelper.GetText(df.Names, this.ChartObj.Configuration.Locale);
                ChartResponse.series       = BuildChart(store, kf, ConceptCodelists);
                ChartResponse.primary_name =
                    (this.ChartObj.ObsValue[0] == "v") ? Messages.label_varValue :
                    (this.ChartObj.ObsValue[0] == "vt") ? Messages.label_varTrend :
                    (this.ChartObj.ObsValue[0] == "vc") ? Messages.label_varCyclical : string.Empty;
                ChartResponse.secondary_name =
                    (this.ChartObj.ObsValue.Count > 1) ?
                    (this.ChartObj.ObsValue[1] == "v") ? Messages.label_varValue :
                    (this.ChartObj.ObsValue[1] == "vt") ? Messages.label_varTrend :
                    (this.ChartObj.ObsValue[1] == "vc") ? Messages.label_varCyclical : string.Empty : string.Empty;
                ChartResponse.x_name = (!string.IsNullOrEmpty(ChartObj.DimensionAxe)) ? ChartObj.DimensionAxe : kf.TimeDimension.Id;;

                // 23/07/2015
                // calcolo massimo e minimo
                decimal?primary_max   = null;
                decimal?primary_min   = null;
                decimal?secondary_max = null;
                decimal?secondary_min = null;
                decimal costantemax   = 1.1m;
                decimal costantemin   = 0.9m;

                foreach (serieType serie in ChartResponse.series)
                {
                    if (serie.axisYType == "secondary")
                    {
                        //fabio 12/08/2015
                        //decimal max = (decimal)serie.dataPoints.Where(m => m.y != null).Max(d => d.y);
                        decimal max = Convert.ToDecimal(serie.dataPoints.Where(m => m.y != null).Max(d => d.y));
                        if (secondary_max == null || max > secondary_max)
                        {
                            secondary_max = max;
                        }

                        //fabio 12/08/2015
                        //decimal min = (decimal)serie.dataPoints.Where(m => m.y != null).Min(d => d.y);
                        decimal min = Convert.ToDecimal(serie.dataPoints.Where(m => m.y != null).Min(d => d.y));
                        if (secondary_min == null || min < secondary_min)
                        {
                            secondary_min = min;
                        }

                        //fabio 12/08/2015
                        if (secondary_min == secondary_max)
                        {
                            secondary_min = secondary_min * costantemin; secondary_max = secondary_max * costantemax;
                        }
                    }
                    else
                    {
                        //fabio 12/08/2015
                        //decimal max = (decimal)serie.dataPoints.Where(m => m.y != null).Max(d => d.y);
                        decimal max = Convert.ToDecimal(serie.dataPoints.Where(m => m.y != null).Max(d => d.y));
                        if (primary_max == null || max > primary_max)
                        {
                            primary_max = max;
                        }

                        //fabio 12/08/2015
                        //decimal min = (decimal)serie.dataPoints.Where(m => m.y != null).Min(d => d.y);
                        decimal min = Convert.ToDecimal(serie.dataPoints.Where(m => m.y != null).Min(d => d.y));
                        if (primary_min == null || min < primary_min)
                        {
                            primary_min = min;
                        }

                        //fabio 12/08/2015
                        if (primary_min == primary_max)
                        {
                            primary_min = primary_min * costantemin; primary_max = primary_max * costantemax;
                        }
                    }
                }
                if (primary_max != null && primary_min != null)
                {
                    //decimal delta = (decimal)primary_max - (decimal)primary_min;
                    //ChartResponse.primary_max = (decimal)primary_max;
                    //ChartResponse.primary_min = (decimal)primary_min;

                    if (primary_max > 0)
                    {
                        ChartResponse.primary_max = (decimal)(primary_max * 1.1m);
                    }
                    else if (primary_max == 0)
                    {
                        ChartResponse.primary_max = (decimal) - 1.1m;
                    }
                    else
                    {
                        ChartResponse.primary_max = (decimal)(primary_max * 0.9m);
                    }

                    if (primary_min > 0)
                    {
                        ChartResponse.primary_min = (decimal)(primary_min * 0.9m);
                    }
                    else if (primary_min == 0)
                    {
                        ChartResponse.primary_min = (decimal) - 1.1m;
                    }
                    else
                    {
                        ChartResponse.primary_min = (decimal)(primary_min * 1.1m);
                    }
                }
                if (secondary_max != null && secondary_min != null)
                {
                    //ChartResponse.secondary_max = (decimal)secondary_max;
                    //ChartResponse.secondary_min = (decimal)secondary_min;

                    if (secondary_max > 0)
                    {
                        ChartResponse.secondary_max = (decimal)(secondary_max * 1.1m);
                    }
                    else if (secondary_max == 0)
                    {
                        ChartResponse.secondary_max = (decimal) - 1.1m;
                    }
                    else
                    {
                        ChartResponse.secondary_max = (decimal)(secondary_max * 0.9m);
                    }

                    if (secondary_min > 0)
                    {
                        ChartResponse.secondary_min = (decimal)(secondary_min * 0.9m);
                    }
                    else if (secondary_min == 0)
                    {
                        ChartResponse.secondary_min = (decimal) - 1.1m;
                    }
                    else
                    {
                        ChartResponse.secondary_min = (decimal)(secondary_min * 1.1m);
                    }
                }

                this.SessionObj.SavedChart = ser.Serialize(ChartResponse);

                // +++ Caching +++
                if (ChartObj.WidgetId > 0 && UseWidgetCache)
                {
                    cache.InsertWidget(ChartObj.WidgetId, this.SessionObj.SavedChart, ChartObj.Configuration.Locale);
                }

                return(this.SessionObj);
            }
            catch (Exception ex)
            {
                Logger.Warn(ex.Message, ex);
                throw ex;
            }
        }
コード例 #19
0
ファイル: Dimension.cs プロジェクト: alcardac/SDMX_BUILD_LOAD
        public void Merge(ICodelistObject codelist)
        {
            Codelist _codelist = new Codelist(codelist);
            _codelistItems = _codelist.Items;
            this._names = new List<TextTypeWrapper>();
            foreach (ITextTypeWrapper text in codelist.Names)
            {
                this._names.Add(new TextTypeWrapper(text.Locale, text.Value));
            }

            this._descriptions = new List<TextTypeWrapper>();
            foreach (ITextTypeWrapper text in codelist.Descriptions)
            {
                this._descriptions.Add(new TextTypeWrapper(text.Locale, text.Value));
            }
        }
コード例 #20
0
        private ICodelistObject GetTimeCodeList(ICodelistObject FreqCodelist)
        {
            ICodelistObject CL_TIME_MA = FreqCodelist;// GetCodeListCostraint(df, kf, kf.TimeDimension);

            if (CL_TIME_MA == null ||
                CL_TIME_MA.Items == null ||
                CL_TIME_MA.Items.Count != 2)
            {
                return(CL_TIME_MA);
            }

            //string format_time = (CL_TIME_MA.Items[0].Id.Contains("-")) ? "yyyy-MM-dd" : "yyyy";
            string time_min_normal = CL_TIME_MA.Items[0].Id;
            string time_max_normal = CL_TIME_MA.Items[1].Id;

            /*fabio 04/11/2015 v3.0.0.0*/
            if (time_min_normal.CompareTo(time_max_normal) > 0)
            {
                time_max_normal = CL_TIME_MA.Items[0].Id;
                time_min_normal = CL_TIME_MA.Items[1].Id;
            }
            else
            {
                time_max_normal = CL_TIME_MA.Items[1].Id;
                time_min_normal = CL_TIME_MA.Items[0].Id;
            }
            /*fine fabio 04/11/2015 v3.0.0.0*/

            //DA FARE
            //string FrequencyDominant = "A";
            string          FrequencyDominant = null;
            ICodelistObject codelistFreq      = this._codelistCache.GetArtefact(_keyFamily.FrequencyDimension);


            if (codelistFreq != null)
            {
                FrequencyDominant = codelistFreq.Items.First().Id;
            }
            //FrequencyDominant = this._codelistCache[kf.FrequencyDimension.Id].First();
            if (FrequencyDominant == null)
            {
                FrequencyDominant = "A";
                if (FreqCodelist.Items.Count(c => c.Id.ToUpper() == "S") > 0)
                {
                    FrequencyDominant = "S";
                }
                if (FreqCodelist.Items.Count(c => c.Id.ToUpper() == "Q") > 0)
                {
                    FrequencyDominant = "Q";
                }
                if (FreqCodelist.Items.Count(c => c.Id.ToUpper() == "M") > 0)
                {
                    FrequencyDominant = "M";
                }
            }
            if (!CL_TIME_MA.Items[0].Id.Contains("-"))
            {
                time_min_normal = string.Format("{0}-{1}-{2}", CL_TIME_MA.Items[0].Id, "01", "01");
                time_max_normal = string.Format("{0}-{1}-{2}", CL_TIME_MA.Items[1].Id, "01", "01");
            }
            else
            {
                var time_p_c = CL_TIME_MA.Items[0].Id.Split('-');
                if (time_p_c.Length == 2)
                {
                    int mul =
                        (FrequencyDominant == "M") ? 1 :
                        (FrequencyDominant == "Q") ? 3 :
                        (FrequencyDominant == "S") ? 6 : 0;

                    int t_fix = (int.Parse(time_p_c[1].Substring(1))) * mul;
                    time_min_normal = string.Format("{0}-{1}-{2}", time_p_c[0], (t_fix > 9) ? t_fix.ToString() : "0" + t_fix.ToString(), "01");
                    time_p_c        = CL_TIME_MA.Items[1].Id.Split('-');
                    t_fix           = (int.Parse(time_p_c[1].Substring(1))) * mul;
                    time_max_normal = string.Format("{0}-{1}-{2}", time_p_c[0], (t_fix > 9) ? t_fix.ToString() : "0" + t_fix.ToString(), "01");
                }
                if (CL_TIME_MA.Items[0].Id.Contains("S"))
                {
                    var time_p = CL_TIME_MA.Items[0].Id.Split('-');
                    int t_fix  = (int.Parse(time_p[1].Substring(1))) * 6;
                    time_min_normal = string.Format("{0}-{1}-{2}", time_p[0], (t_fix > 9) ? t_fix.ToString() : "0" + t_fix.ToString(), "01");

                    time_p          = CL_TIME_MA.Items[1].Id.Split('-');
                    t_fix           = (int.Parse(time_p[1].Substring(1))) * 6;
                    time_max_normal = string.Format("{0}-{1}-{2}", time_p[0], (t_fix > 9) ? t_fix.ToString() : "0" + t_fix.ToString(), "01");
                }
                if (CL_TIME_MA.Items[0].Id.Contains("Q"))
                {
                    var time_p = CL_TIME_MA.Items[0].Id.Split('-');
                    int t_fix  = ((int.Parse(time_p[1].Substring(1))) * 3);
                    time_min_normal = string.Format("{0}-{1}-{2}", time_p[0], (t_fix > 9) ? t_fix.ToString() : "0" + t_fix.ToString(), "01");

                    time_p          = CL_TIME_MA.Items[1].Id.Split('-');
                    t_fix           = ((int.Parse(time_p[1].Substring(1))) * 3);
                    time_max_normal = string.Format("{0}-{1}-{2}", time_p[0], (t_fix > 9) ? t_fix.ToString() : "0" + t_fix.ToString(), "01");
                }
                if (CL_TIME_MA.Items[0].Id.Contains("M"))
                {
                    var time_p = CL_TIME_MA.Items[0].Id.Split('-');
                    int t_fix  = (int.Parse(time_p[1].Substring(1))) * 1;
                    time_min_normal = string.Format("{0}-{1}-{2}", time_p[0], (t_fix > 9) ? t_fix.ToString() : "0" + t_fix.ToString(), "01");

                    time_p          = CL_TIME_MA.Items[1].Id.Split('-');
                    t_fix           = (int.Parse(time_p[1].Substring(1))) * 1;
                    time_max_normal = string.Format("{0}-{1}-{2}", time_p[0], (t_fix > 9) ? t_fix.ToString() : "0" + t_fix.ToString(), "01");
                }
            }

            DateTime MinDate = DateTime.ParseExact(time_min_normal, "yyyy-MM-dd", CultureInfo.CurrentCulture, DateTimeStyles.None);
            DateTime MaxDate = DateTime.ParseExact(time_max_normal, "yyyy-MM-dd", CultureInfo.CurrentCulture, DateTimeStyles.None);

            /*CultureInfo enEn = new CultureInfo("en");
             * DateTime MinDate = DateTime.ParseExact(time_min_normal, "yyyy-MM-dd", enEn, DateTimeStyles.None);
             * DateTime MaxDate = DateTime.ParseExact(time_max_normal, "yyyy-MM-dd", enEn, DateTimeStyles.None);
             */

            ICodelistMutableObject CL_TIME = new CodelistMutableCore();

            CL_TIME.Id       = CL_TIME_MA.Id;
            CL_TIME.AgencyId = CL_TIME_MA.AgencyId;
            CL_TIME.Version  = CL_TIME_MA.Version;

            CL_TIME_MA.Names.ToList().ForEach(n => CL_TIME.AddName(n.Locale, n.Value));


            DateTime ActualDate = MinDate;

            switch (FrequencyDominant)
            {
            case "A":
                #region Aggiungo gli Annual
                while (ActualDate.CompareTo(MaxDate) <= 0)
                {
                    ICodeMutableObject code = new CodeMutableCore();
                    code.Id = ActualDate.Year.ToString();
                    code.AddName("en", code.Id);
                    CL_TIME.AddItem(code);

                    ActualDate = ActualDate.AddYears(1);
                }
                #endregion
                break;

            case "S":
                #region Aggiungo gli Semestrali
                while (ActualDate.CompareTo(MaxDate) <= 0)
                {
                    ICodeMutableObject code = new CodeMutableCore();
                    code.Id = ActualDate.Year.ToString() + "-S" + (ActualDate.Month < 6 ? "1" : "2");
                    code.AddName("en", code.Id);
                    CL_TIME.AddItem(code);

                    ActualDate = ActualDate.AddMonths(6);
                }
                #endregion
                break;

            case "Q":
                #region Aggiungo i Quartely
                while (ActualDate.CompareTo(MaxDate) <= 0)
                {
                    ICodeMutableObject code = new CodeMutableCore();
                    code.Id = ActualDate.Year.ToString() + "-Q" + ((ActualDate.Month - 1) / 3 + 1).ToString();
                    code.AddName("en", code.Id);
                    CL_TIME.AddItem(code);

                    ActualDate = ActualDate.AddMonths(3);
                }
                #endregion
                break;

            case "M":
                #region Aggiungo i Mensili
                while (ActualDate.CompareTo(MaxDate) <= 0)
                {
                    ICodeMutableObject code = new CodeMutableCore();
                    code.Id = ActualDate.ToString("yyyy-MM");
                    code.AddName("en", code.Id);
                    CL_TIME.AddItem(code);

                    ActualDate = ActualDate.AddMonths(1);
                }
                #endregion
                break;

            default:
                break;
            }

            return(CL_TIME.ImmutableInstance);
        }
コード例 #21
0
        /// <summary>
        /// Initializes a new instance of the <see cref="CodeTreeBuilder"/> class.
        /// </summary>
        /// <param name="codelist">
        /// The codelist.
        /// </param>
        /// <exception cref="ArgumentNullException">
        /// codelist is null
        /// </exception>
        public CodeTreeBuilder(ICodelistObject codelist)
        {
            if (codelist == null)
            {
                throw new ArgumentNullException("codelist");
            }

            this._codeList = codelist;
            this._idNodeMap = new Dictionary<ICode, JsTreeNode>(codelist.Items.Count);
            this._rootNodes = new List<JsTreeNode>(codelist.Items.Count);
            this._checkedNodes = new Dictionary<ICode, JsTreeNode>(codelist.Items.Count);
            this.BuildIdNodeMap();
        }
コード例 #22
0
        /// <summary>
        /// Get the code list for the specified component
        /// </summary>
        /// <param name="component">
        /// The coded component
        /// </param>
        /// <returns>
        /// The artefact or null if it is not in the <see cref="_codelistCache"/>
        /// </returns>
        public ICodelistObject GetCachedCodelist(IComponent component)
        {
            ICodelistObject codelist = this._codelistCache.GetArtefact(component);

            return(codelist);
        }
コード例 #23
0
        /// <summary>
        /// Update the codelist cache with the specified codelist and component
        /// </summary>
        /// <param name="codelist">
        /// The codelist
        /// </param>
        /// <param name="component">
        /// The component
        /// </param>
        public void UpdateCodelistMap(ICodelistObject codelist, IComponent component)
        {
            if (component.Id == KeyFamily.TimeDimension.Id)
            { this._codelistCache.Update(component, GetTimeCodeList(codelist));
            this._codeTreeMap[component] = new CodeTreeBuilder(GetTimeCodeList(codelist));
            }
            else
            { this._codelistCache.Update(component, codelist);
              this._codeTreeMap[component] = new CodeTreeBuilder(codelist);
            }

            if (component.HasCodedRepresentation() && !string.IsNullOrEmpty(component.Representation.Representation.MaintainableReference.MaintainableId))
            {
                this.BuildCodeDescriptionMap(component);
            }
        }
コード例 #24
0
        public SessionImplObject GetData(out object DataStream, SessionQuery query)
        {
            try
            {
                // Init session objects
                if (this.SessionObj == null)
                {
                    this.SessionObj            = new SessionImplObject();
                    this.SessionObj.SdmxObject = new SdmxObjectsImpl();
                }


                if (BDO == null || GetSDMXObject == null)
                {
                    throw new Exception(Messages.label_error_network + " " + DataObj.Configuration.Title);
                }


                codemapWidget = new CodemapWidget(new GetCodemapObject()
                {
                    Configuration    = this.DataObj.Configuration,
                    Dataflow         = this.DataObj.Dataflow,
                    PreviusCostraint = this.DataObj.Criteria
                },
                                                  this.SessionObj, query);
                //ISdmxObjects structure = codemapWidget.GetDsd();
                ISdmxObjects         structure = query.Structure;
                IDataflowObject      df        = structure.Dataflows.FirstOrDefault();
                IDataStructureObject kf        = structure.DataStructures.First();
                if (df == null)
                {
                    throw new InvalidOperationException("Dataflow is not set");
                }

                /****************/
                // Get all codelist
                /****************/
                //Dictionary<string, ICodelistObject> ConceptCodelists = codemapWidget.GetCodelistMap(df, kf, true);
                Dictionary <string, ICodelistObject> ConceptCodelists = codemapWidget.GetCodelistMap(query, false);
                ComponentCodeDescriptionDictionary   codemap          = new ComponentCodeDescriptionDictionary();
                foreach (string ConceptId in ConceptCodelists.Keys)
                {
                    ICodelistObject             codelist = ConceptCodelists[ConceptId];
                    Dictionary <string, string> codes    = new Dictionary <string, string>();
                    foreach (ICode codeItem in codelist.Items)
                    {
                        codes.Add(codeItem.Id, TextTypeHelper.GetText(codeItem.Names, this.DataObj.Configuration.Locale));
                    }
                    codemap.Add(ConceptId, codes);
                }
                /****************/
                //codemapWidget.GetCodeListCostraint(df,kf,component)

                this.SessionObj.MergeObject(codemapWidget.SessionObj);
                int num1;
                #region Gestione last period
                if (this.DataObj.Criteria.ContainsKey(kf.TimeDimension.Id) &&
                    this.DataObj.Criteria[kf.TimeDimension.Id].Count == 1 &&
                    int.TryParse(this.DataObj.Criteria[kf.TimeDimension.Id].First(), out num1) &&
                    !this.DataObj.Layout.axis_z.Contains(kf.TimeDimension.Id))
                {
                    int offsetTime = int.Parse(this.DataObj.Criteria[kf.TimeDimension.Id].First());
                    var codMap     = codemap;
                    int lengthTime = codMap[kf.TimeDimension.Id].Count;

                    if ((lengthTime - offsetTime) >= 0)
                    {
                        var           codes         = codMap[kf.TimeDimension.Id].Reverse().Take(offsetTime);
                        List <string> _criteriaTime = (from c in codes select c.Key).ToList <string>();

                        this.DataObj.Criteria[kf.TimeDimension.Id] = new List <string>();
                        this.DataObj.Criteria[kf.TimeDimension.Id].Add(_criteriaTime.Last());
                        this.DataObj.Criteria[kf.TimeDimension.Id].Add(_criteriaTime.First());
                    }
                    else
                    {
                        this.DataObj.Criteria[kf.TimeDimension.Id] = new List <string>();
                        this.DataObj.Criteria[kf.TimeDimension.Id].Add(codemap[kf.TimeDimension.Id].First().Key);
                        this.DataObj.Criteria[kf.TimeDimension.Id].Add(codemap[kf.TimeDimension.Id].Last().Key);
                    }
                }
                #endregion

                LayoutObj           layObj    = InitLayout(df, kf);
                List <DataCriteria> Criterias = BDO.InitCriteria(kf, this.DataObj.Criteria);
                //query.GetCriteria();

                Dictionary <string, List <DataChacheObject> > DataCache = SessionObj.DataCache;
                List <string>       ret            = null;
                List <DataCriteria> QueryCriterias = new List <DataCriteria>();

                if (query.Criteria != null)   //criteri nulli se proviene da un template
                {
                    if (query._store != null) //.Count == 1)
                    {
                        query.SetCriteriaTime(this.DataObj.Criteria[kf.TimeDimension.Id]);
                    }

                    if (query.Criteria.TryGetValue(kf.TimeDimension.Id, out ret))
                    {
                        if (ret.Count == 1)
                        {
                            query.SetCriteriaTime(this.DataObj.Criteria[kf.TimeDimension.Id]);
                        }
                    }


                    QueryCriterias = query.GetCriteria();

                    /*if (query._store == null) //.Count == 1)
                     * { QueryCriterias = Criterias; }
                     * else
                     * { QueryCriterias = query.GetCriteria(); }*/
                }
                else
                {
                    QueryCriterias = Criterias;
                }


                //aggiunta da fabio
                IDataSetStore store;
                if (query._store != null)
                {
                    store = query._store;
                }
                else
                {
                    //store = BDO.GetDataset(df, kf, Criterias, ref DataCache, _useAttr);
                    store        = BDO.GetDataset(df, kf, QueryCriterias, ref DataCache, _useAttr, query);
                    query._store = store;
                }
                //fine nuovo

                SessionObj.DataCache = DataCache;

                DataStream = new DataObjectForStreaming()
                {
                    Configuration = this.DataObj.Configuration,
                    store         = store,
                    layObj        = layObj,
                    Criterias     = Criterias,
                    structure     = structure,
                    codemap       = codemap
                };


                return(this.SessionObj);
            }
            catch (Exception ex)
            {
                Logger.Warn(ex.Message, ex);
                throw ex;
            }
        }
コード例 #25
0
        private List <serieType> BuildChart(
            IDataSetStore store,
            IDataStructureObject kf,
            Dictionary <string, ICodelistObject> codelists)
        {
            List <string> sort = new List <string>();

            foreach (string col in store.GetAllColumns())
            {
                if (col != kf.TimeDimension.Id && col != kf.PrimaryMeasure.Id)
                {
                    sort.Add(col);
                }
            }
            store.SetSort(sort);

            // Dimensione sull'asse X
            string XConcept =
                (!string.IsNullOrEmpty(ChartObj.DimensionAxe)) ?
                ChartObj.DimensionAxe :
                kf.TimeDimension.Id;
            // Codici sull'asse X
            Dictionary <string, int> XPosition = new Dictionary <string, int>();

            if (codelists.ContainsKey(XConcept))
            {
                ICodelistObject CCodes = codelists[XConcept];
                for (int i = 0; i < CCodes.Items.Count; i++)
                {
                    XPosition.Add(CCodes.Items[i].Id, i);
                }
            }

            #region Dimensione usata per la descrizione
            string DescConcept  = string.Empty;
            bool   single_serie = true;
            foreach (var obj in ChartObj.Criteria)
            {
                if (//obj.Key != kf.TimeDimension.Id &&
                    obj.Key != kf.FrequencyDimension.Id)
                {
                    DescConcept = obj.Key;
                    if (obj.Value.Count > 1 && obj.Key != XConcept)
                    {
                        single_serie = false;
                        DescConcept  = obj.Key;
                        break;
                    }
                }
            }

            bool inLegend = !single_serie;
            inLegend = inLegend || (single_serie && ChartObj.ObsValue.Count > 1);

            #endregion

            List <serieType> series   = new List <serieType>();
            List <serieType> series_s = new List <serieType>();
            var v = new Dictionary <string, decimal>();

            //IDataReader datareader = store.CreateDataReader(true);
            IDataReader datareader = store.CreateDataReader(false);
            while (datareader.Read())
            {
                decimal obs = 0;
                object  vt  = null;
                object  vc  = null;

                var obs_val   = datareader[kf.PrimaryMeasure.Id];
                var xcode     = (string)datareader[XConcept];
                var xCodeName = (string)TextTypeHelper.GetText(codelists[XConcept].GetCodeById(xcode).Names, this.ChartObj.Configuration.Locale);

                //fabio 12/08/2015
                //string customKeyCode = (ChartObj.CustomKey != null) ? datareader[ChartObj.CustomKey].ToString() : string.Empty;
                string customKeyCode = (ChartObj.CustomKey != null && ChartObj.CustomKey != "") ? datareader[ChartObj.CustomKey].ToString() : string.Empty;
                var    customSerie   = (ChartObj.CustomChartType != null) ?
                                       (!string.IsNullOrEmpty(customKeyCode)) ?
                                       (from c in ChartObj.CustomChartType where c.code == customKeyCode select c).FirstOrDefault() :
                                       null : null;

                string serieKey  = string.Empty;
                string serieName = string.Empty;

                bool is_obs_value = false;
                try
                {
                    obs          = Convert.ToDecimal(obs_val.ToString(), cFrom);
                    is_obs_value = true;
                    obs_val      = Math.Round(obs, 1);
                }
                catch
                {
                    //fabio 12/08/2015 aggiunta
                    obs_val      = null;
                    is_obs_value = true;

                    //fabio 12/08/2015 eliminata
                    //is_obs_value = false;
                }

                // if not time serie no varation
                if (XConcept == kf.TimeDimension.Id)
                {
                    #region Calcolo variazioni

                    if (is_obs_value)
                    {
                        var time_p = xcode;
                        int anno   = 0;
                        int period = 0;

                        bool _errTimePeriod = false;

                        bool _annual = !((string)time_p).Contains("-");
                        bool _quater = false;
                        bool _seme   = false;

                        #region ESTRAGGO ANNO E PERIOD
                        if (_annual)
                        {
                            _errTimePeriod = !(int.TryParse(((string)time_p), out anno));
                        }
                        else
                        {
                            _errTimePeriod = !(int.TryParse(((string)time_p).Split('-')[0], out anno));

                            string _p = ((string)time_p).Split('-')[1];

                            if (_quater = _p.StartsWith("Q"))
                            {
                                _p = _p.Substring(1);
                            }
                            if (_seme = _p.StartsWith("S"))
                            {
                                _p = _p.Substring(1);
                            }

                            _errTimePeriod = !(int.TryParse(_p, out period));
                        }
                        #endregion

                        if (!_errTimePeriod)
                        {
                            string serieKeyStr = string.Empty;
                            string _sep        = string.Empty;
                            foreach (var dim in kf.DimensionList.Dimensions)
                            {
                                serieKeyStr += ((dim.Id != XConcept) ? _sep + datareader[dim.Id] : string.Empty);
                                _sep         = "+";
                                if (dim.Id == DescConcept)
                                {
                                    serieName =
                                        TextTypeHelper.GetText(
                                            codelists[DescConcept].GetCodeById(datareader[dim.Id].ToString()).Names,
                                            this.ChartObj.Configuration.Locale);
                                }
                            }
                            serieKey = serieKeyStr;

                            string vi_k = string.Empty;
                            string vf_k = string.Empty;

                            // Calcolo variazione congiunturale

                            vf_k = serieKeyStr + anno + "_" + (period);
                            if (!_annual)
                            {
                                if (period == 1)
                                {
                                    if (_seme)
                                    {
                                        vi_k = serieKeyStr + (anno - 1) + "_2";
                                    }
                                    else if (_quater)
                                    {
                                        vi_k = serieKeyStr + (anno - 1) + "_4";
                                    }
                                    else
                                    {
                                        vi_k = serieKeyStr + (anno - 1) + "_12";
                                    }
                                }
                                else
                                {
                                    vi_k = serieKeyStr + anno + "_" + (period - 1);
                                }
                            }
                            else
                            {
                                vi_k = serieKeyStr + (anno - 1) + "_" + (period);
                            }

                            var vi = (v.ContainsKey(vi_k.ToString())) ? (object)v[vi_k] : null;

                            try
                            {
                                decimal _vi;
                                // non specificare il cFrom nella conversione
                                // poichè vi è il valore gia convertito
                                _vi = Convert.ToDecimal(vi.ToString());
                                //_vi = Convert.ToDecimal(vi.ToString(), cFrom);
                                if (_vi == 0)
                                {
                                    vc = null;
                                }
                                else
                                {
                                    vc = Math.Round((((obs - _vi) / _vi) * 100), 1);
                                }
                            }
                            catch {
                                vc = null;
                            }

                            // Calcolo variazione tendenziale
                            vi_k = serieKeyStr + (anno - 1) + "_" + (period);
                            vf_k = serieKeyStr + anno + "_" + (period);
                            vi   = (v.ContainsKey(vi_k.ToString())) ? (object)v[vi_k] : null;

                            try
                            {
                                decimal _vi;
                                _vi = Convert.ToDecimal(vi.ToString());
                                //_vi = Convert.ToDecimal(vi.ToString(), cFrom);
                                if (_vi == 0)
                                {
                                    vc = null;
                                }
                                else
                                {
                                    vt = Math.Round((((obs - _vi) / _vi) * 100), 1);
                                }
                            }
                            catch
                            {
                                vt = null;
                            }

                            v.Add(vf_k, obs);
                        }
                    }
                    #endregion
                }
                else
                {
                    // Retrive unique key and label serie
                    string serieKeyStr = string.Empty;
                    string _sep        = string.Empty;
                    foreach (var dim in kf.DimensionList.Dimensions)
                    {
                        serieKeyStr += ((dim.Id != XConcept) ? _sep + datareader[dim.Id] : string.Empty);
                        _sep         = "+";
                        if (dim.Id == DescConcept)
                        {
                            serieName =
                                TextTypeHelper.GetText(
                                    codelists[DescConcept].GetCodeById(datareader[dim.Id].ToString()).Names,
                                    this.ChartObj.Configuration.Locale);
                        }
                    }
                    serieKey = serieKeyStr;
                }

                #region Primary Serie
                object primary_obs =
                    (ChartObj.ObsValue[0] == "v") ? (is_obs_value) ? obs_val : null :
                    (ChartObj.ObsValue[0] == "vt") ? vt :
                    (ChartObj.ObsValue[0] == "vc") ? vc : null;

                bool      isNew    = false;
                serieType newSerie = null;
                newSerie = series.Find(s => s.serieKey == ChartObj.ObsValue[0] + "_" + serieKey);//SerieName);

                if (newSerie == null)
                {
                    string _type = (customSerie != null) ? customSerie.chartType.ToString() : ChartObj.ChartType;

                    string _name = (ChartObj.ObsValue[0] == "vt") ? Messages.label_varTrend + "% " :
                                   (ChartObj.ObsValue[0] == "vc") ? Messages.label_varCyclical + "% " :
                                   (single_serie)? Messages.label_varValue:    string.Empty;

                    if (!single_serie)
                    {
                        _name += ((customSerie != null) ? customSerie.title.ToString() : serieName);
                    }

                    isNew    = true;
                    newSerie = new serieType()
                    {
                        name          = _name,
                        serieKey      = ChartObj.ObsValue[0] + "_" + serieKey,
                        showInLegend  = inLegend,
                        type          = _type,
                        dataPoints    = new List <dataPointType>(),
                        axisYType     = "primary",
                        lineThickness = 1f,
                        markerType    = "circle", //"circle", "square", "cross", "none"
                        markerSize    = (_type == "bubble" || _type == "scatter") ? 10f : 1f,
                    };
                }

                newSerie.dataPoints.Add(new dataPointType()
                {
                    label      = xCodeName,
                    legendText = xCodeName,
                    y          = primary_obs,
                    x          = XPosition[xcode]
                });

                if (isNew)
                {
                    series.Add(newSerie);
                }
                #endregion

                // if not time serie no secondary
                if (XConcept == kf.TimeDimension.Id)
                {
                    #region Seconday serie
                    if (ChartObj.ObsValue.Count > 1)
                    {
                        string _type = (customSerie != null) ? customSerie.chartType.ToString() : ChartObj.ChartType;
                        string _name = (ChartObj.ObsValue[1] == "vt") ? Messages.label_varTrend + "% " :
                                       (ChartObj.ObsValue[1] == "vc") ? Messages.label_varCyclical + "% " : Messages.label_varValue + " ";

                        if (!single_serie)
                        {
                            _name += ((customSerie != null) ? customSerie.title.ToString() : serieName);
                        }
                        object secondary_obs =
                            (ChartObj.ObsValue[1] == "v") ? (is_obs_value) ? obs_val : null :
                            (ChartObj.ObsValue[1] == "vt") ? vt :
                            (ChartObj.ObsValue[1] == "vc") ? vc : null;

                        bool      isNew_s    = false;
                        serieType newSerie_s = null;
                        newSerie_s = series_s.Find(s => s.serieKey == ChartObj.ObsValue[1] + "_" + serieKey);//SerieName);
                        if (newSerie_s == null)
                        {
                            isNew_s    = true;
                            newSerie_s = new serieType()
                            {
                                name          = _name,
                                serieKey      = ChartObj.ObsValue[1] + "_" + serieKey,
                                showInLegend  = inLegend,
                                type          = _type,
                                dataPoints    = new List <dataPointType>(),
                                axisYType     = "secondary",
                                lineThickness = 1f,
                                markerType    = "circle", //"circle", "square", "cross", "none"
                                markerSize    = (_type == "bubble" || _type == "scatter") ? 10f : 1f,
                            };
                        }
                        newSerie_s.dataPoints.Add(new dataPointType()
                        {
                            label      = xCodeName,
                            legendText = xCodeName,
                            y          = secondary_obs,
                            x          = XPosition[xcode]
                        });

                        if (isNew_s)
                        {
                            series_s.Add(newSerie_s);
                        }
                    }
                    #endregion
                }
            }
            series.AddRange(series_s);

            #region Series
            foreach (var serie in series)
            {
                var sortedCodes = serie.dataPoints.OrderBy <dataPointType, int>(o => int.Parse(o.x.ToString())).ToArray();
                serie.dataPoints.Clear();
                serie.dataPoints.AddRange(sortedCodes);

                for (int i = 0; i < serie.dataPoints.Count; i++)
                {
                    serie.dataPoints[i].x = i;
                }
            }
            #endregion

            return(series);
        }
コード例 #26
0
        ///////////////////////////////////////////////////////////////////////////////////////////////////
        ////////////BUILD FROM MUTABLE OBJECT                 //////////////////////////////////////////////////
        ///////////////////////////////////////////////////////////////////////////////////////////////////
        #region Constructors and Destructors

        /// <summary>
        /// Initializes a new instance of the <see cref="CodeCore"/> class.
        /// </summary>
        /// <param name="parent">
        /// The parent. 
        /// </param>
        /// <param name="itemMutableObject">
        /// The sdmxObject. 
        /// </param>
        public CodeCore(ICodelistObject parent, ICodeMutableObject itemMutableObject)
            : base(itemMutableObject, parent)
        {
            this.parentCode = string.IsNullOrWhiteSpace(itemMutableObject.ParentCode) ? null : itemMutableObject.ParentCode;
        }
コード例 #27
0
        private ICodelistObject GetTimeCodeList(ISdmxObjects sdmxObjects, ICodelistObject FreqCodelist, IDataStructureObject kf)
        {
            if (this.SessionObj.CodelistConstrained != null && this.SessionObj.CodelistConstrained.ContainsKey(Utils.MakeKey(kf)) &&
                this.SessionObj.CodelistConstrained[Utils.MakeKey(kf)].ContainsKey(kf.TimeDimension.Id))
            {
                ICodelistObject codes = this.SessionObj.CodelistConstrained[Utils.MakeKey(kf)][kf.TimeDimension.Id];
                if (codes != null)
                {
                    return(codes);
                }
            }
            var             codelist   = (from c in sdmxObjects.Codelists where c.Id == kf.TimeDimension.Id select c).FirstOrDefault();
            ICodelistObject CL_TIME_MA = codelist;

            if (CL_TIME_MA == null ||
                CL_TIME_MA.Items == null ||
                CL_TIME_MA.Items.Count != 2)
            {
                return(CL_TIME_MA);
            }

            //string format_time = (CL_TIME_MA.Items[0].Id.Contains("-")) ? "yyyy-MM-dd" : "yyyy";
            string time_min_normal = CL_TIME_MA.Items[0].Id;
            string time_max_normal = CL_TIME_MA.Items[1].Id;

            string FrequencyDominant = "A";

            if (FreqCodelist.Items.Count(c => c.Id.ToUpper() == "S") > 0)
            {
                FrequencyDominant = "S";
            }
            if (FreqCodelist.Items.Count(c => c.Id.ToUpper() == "Q") > 0)
            {
                FrequencyDominant = "Q";
            }
            if (FreqCodelist.Items.Count(c => c.Id.ToUpper() == "M") > 0)
            {
                FrequencyDominant = "M";
            }

            if (!CL_TIME_MA.Items[0].Id.Contains("-"))
            {
                time_min_normal = string.Format("{0}-{1}-{2}", CL_TIME_MA.Items[0].Id, "01", "01");
                time_max_normal = string.Format("{0}-{1}-{2}", CL_TIME_MA.Items[1].Id, "01", "01");
            }
            else
            {
                var time_p_c = CL_TIME_MA.Items[0].Id.Split('-');
                if (time_p_c.Length == 2)
                {
                    int mul =
                        (FrequencyDominant == "M") ? 1 :
                        (FrequencyDominant == "Q") ? 3 :
                        (FrequencyDominant == "S") ? 6 : 0;

                    int t_fix = (int.Parse(time_p_c[1].Substring(1))) * mul;
                    time_min_normal = string.Format("{0}-{1}-{2}", time_p_c[0], (t_fix > 9) ? t_fix.ToString() : "0" + t_fix.ToString(), "01");
                    time_p_c        = CL_TIME_MA.Items[1].Id.Split('-');
                    t_fix           = (int.Parse(time_p_c[1].Substring(1))) * mul;
                    time_max_normal = string.Format("{0}-{1}-{2}", time_p_c[0], (t_fix > 9) ? t_fix.ToString() : "0" + t_fix.ToString(), "01");
                }
                if (CL_TIME_MA.Items[0].Id.Contains("S"))
                {
                    var time_p = CL_TIME_MA.Items[0].Id.Split('-');
                    int t_fix  = (int.Parse(time_p[1].Substring(1))) * 6;
                    time_min_normal = string.Format("{0}-{1}-{2}", time_p[0], (t_fix > 9) ? t_fix.ToString() : "0" + t_fix.ToString(), "01");

                    time_p          = CL_TIME_MA.Items[1].Id.Split('-');
                    t_fix           = (int.Parse(time_p[1].Substring(1))) * 6;
                    time_max_normal = string.Format("{0}-{1}-{2}", time_p[0], (t_fix > 9) ? t_fix.ToString() : "0" + t_fix.ToString(), "01");
                }
                if (CL_TIME_MA.Items[0].Id.Contains("Q"))
                {
                    var time_p = CL_TIME_MA.Items[0].Id.Split('-');
                    int t_fix  = ((int.Parse(time_p[1].Substring(1))) * 3);
                    time_min_normal = string.Format("{0}-{1}-{2}", time_p[0], (t_fix > 9) ? t_fix.ToString() : "0" + t_fix.ToString(), "01");

                    time_p          = CL_TIME_MA.Items[1].Id.Split('-');
                    t_fix           = ((int.Parse(time_p[1].Substring(1))) * 3);
                    time_max_normal = string.Format("{0}-{1}-{2}", time_p[0], (t_fix > 9) ? t_fix.ToString() : "0" + t_fix.ToString(), "01");
                }
                if (CL_TIME_MA.Items[0].Id.Contains("M"))
                {
                    var time_p = CL_TIME_MA.Items[0].Id.Split('-');
                    int t_fix  = (int.Parse(time_p[1].Substring(1))) * 1;
                    time_min_normal = string.Format("{0}-{1}-{2}", time_p[0], (t_fix > 9) ? t_fix.ToString() : "0" + t_fix.ToString(), "01");

                    time_p          = CL_TIME_MA.Items[1].Id.Split('-');
                    t_fix           = (int.Parse(time_p[1].Substring(1))) * 1;
                    time_max_normal = string.Format("{0}-{1}-{2}", time_p[0], (t_fix > 9) ? t_fix.ToString() : "0" + t_fix.ToString(), "01");
                }
            }


            DateTime MinDate = DateTime.ParseExact(time_min_normal, "yyyy-MM-dd", CultureInfo.CurrentCulture, DateTimeStyles.None);
            DateTime MaxDate = DateTime.ParseExact(time_max_normal, "yyyy-MM-dd", CultureInfo.CurrentCulture, DateTimeStyles.None);

            ICodelistMutableObject CL_TIME = new CodelistMutableCore();

            CL_TIME.Id       = CL_TIME_MA.Id;
            CL_TIME.AgencyId = CL_TIME_MA.AgencyId;
            CL_TIME.Version  = CL_TIME_MA.Version;

            CL_TIME_MA.Names.ToList().ForEach(n => CL_TIME.AddName(n.Locale, n.Value));

            DateTime ActualDate = MinDate;

            switch (FrequencyDominant)
            {
            case "A":
                #region Aggiungo gli Annual
                while (ActualDate.CompareTo(MaxDate) < 0)
                {
                    ICodeMutableObject code = new CodeMutableCore();
                    code.Id = ActualDate.Year.ToString();
                    code.AddName("en", code.Id);
                    CL_TIME.AddItem(code);

                    ActualDate = ActualDate.AddYears(1);
                }
                #endregion
                break;

            case "S":
                #region Aggiungo gli Semestrali
                while (ActualDate.CompareTo(MaxDate) < 0)
                {
                    ICodeMutableObject code = new CodeMutableCore();
                    code.Id = ActualDate.Year.ToString() + "-S" + (ActualDate.Month < 6 ? "1" : "2");
                    code.AddName("en", code.Id);
                    CL_TIME.AddItem(code);

                    ActualDate = ActualDate.AddMonths(6);
                }
                #endregion
                break;

            case "Q":
                #region Aggiungo i Quartely
                while (ActualDate.CompareTo(MaxDate) < 0)
                {
                    ICodeMutableObject code = new CodeMutableCore();
                    code.Id = ActualDate.Year.ToString() + "-Q" + ((ActualDate.Month - 1) / 3 + 1).ToString();
                    code.AddName("en", code.Id);
                    CL_TIME.AddItem(code);

                    ActualDate = ActualDate.AddMonths(3);
                }
                #endregion
                break;

            case "M":
                #region Aggiungo i Mensili
                while (ActualDate.CompareTo(MaxDate) < 0)
                {
                    ICodeMutableObject code = new CodeMutableCore();
                    code.Id = ActualDate.ToString("yyyy-MM");
                    code.AddName("en", code.Id);
                    CL_TIME.AddItem(code);

                    ActualDate = ActualDate.AddMonths(1);
                }
                #endregion
                break;

            default:
                break;
            }

            return(CL_TIME.ImmutableInstance);
        }
コード例 #28
0
 private void SetCodeDetailPanel(ICodelistObject cl)
 {
     // Verifico se la codelist è final
     if (cl.IsFinal.IsTrue || _action == Action.VIEW)
     {
         // Se final il pulsante di add e le colonne di modifica
         // dei codici non devono apparire
         btnSaveMemoryCodeList.Visible = false;
         if ( _action == Action.VIEW )
         {
             btnAddNewCode.Visible = false;
         }
         else
         {
             if ( cl.IsFinal.IsTrue )
             {
                 btnNewCodeOnFinalStructure.Visible = true;
                 btnNewCode.Visible = false;
                 txt_order_new.Visible = false;
                 lbl_order_new.Visible = false;
                 lblYouAreWorkingOnAFinal.Visible = true;
             }
         }
         AddTextName_update.ucEditMode = false;
         AddTextDescription_update.ucEditMode = false;
         txt_parentid_update.Enabled = false;
         txt_order_update.Enabled = false;
         AnnotationGeneralControl.EditMode = false;
         btnSaveAnnotationCode.Enabled = false;
         btnUpdateCode.Enabled = false;
         //gvCodelistsItem.Columns[gvCodelistsItem.Columns.Count - 1].Visible = false;
         gvCodelistsItem.Columns[gvCodelistsItem.Columns.Count - 2].Visible = false;
         //gvCodelistsItem.Columns[gvCodelistsItem.Columns.Count - 3].Visible = false;
         cmbLanguageForCsv.Visible = false;
         imgImportCsv.Visible = false;
     }
     else
     {
         btnSaveMemoryCodeList.Visible = true;
         btnAddNewCode.Visible = true;
         gvCodelistsItem.Columns[gvCodelistsItem.Columns.Count - 1].Visible = true;
         gvCodelistsItem.Columns[gvCodelistsItem.Columns.Count - 2].Visible = true;
         gvCodelistsItem.Columns[gvCodelistsItem.Columns.Count - 3].Visible = true;
         Utils.PopulateCmbLanguages(cmbLanguageForCsv, AVAILABLE_MODES.MODE_FOR_ADD_TEXT);
         cmbLanguageForCsv.Visible = true;
         imgImportCsv.Visible = true;
     }
 }
コード例 #29
0
        private ICodelistObject GetTimeCodeList(ICodelistObject FreqCodelist, IDataflowObject df, IDataStructureObject kf)
        {
            ICodelistObject CL_TIME_MA = GetCodeList(df, kf, kf.TimeDimension);
            if (CL_TIME_MA == null || CL_TIME_MA.Items == null || CL_TIME_MA.Items.Count != 2)
                return CL_TIME_MA;

            //string format_time = (CL_TIME_MA.Items[0].Id.Contains("-")) ? "yyyy-MM-dd" : "yyyy";
            string time_min_normal = CL_TIME_MA.Items[0].Id;
            string time_max_normal = CL_TIME_MA.Items[1].Id;

            /*fabio 04/11/2015 v3.0.0.0*/
            if (time_min_normal.CompareTo(time_max_normal) > 0)
            {
                time_max_normal = CL_TIME_MA.Items[0].Id;
                time_min_normal = CL_TIME_MA.Items[1].Id;
            }
            else
            {
                time_max_normal = CL_TIME_MA.Items[1].Id;
                time_min_normal = CL_TIME_MA.Items[0].Id;
            }
            /*fine fabio 04/11/2015 v3.0.0.0*/

            string FrequencyDominant = null;
            if (CodemapObj.PreviusCostraint != null
                && CodemapObj.PreviusCostraint.ContainsKey(kf.FrequencyDimension.Id))
                FrequencyDominant = CodemapObj.PreviusCostraint[kf.FrequencyDimension.Id].First();
            if (FrequencyDominant == null)
            {
                FrequencyDominant = "A";
                if (FreqCodelist.Items.Count(c => c.Id.ToUpper() == "S") > 0) FrequencyDominant = "S";
                if (FreqCodelist.Items.Count(c => c.Id.ToUpper() == "Q") > 0) FrequencyDominant = "Q";
                if (FreqCodelist.Items.Count(c => c.Id.ToUpper() == "M") > 0) FrequencyDominant = "M";
            }
            if (!CL_TIME_MA.Items[0].Id.Contains("-"))
            {
                time_min_normal = string.Format("{0}-{1}-{2}", CL_TIME_MA.Items[0].Id, "01", "01");
                time_max_normal = string.Format("{0}-{1}-{2}", CL_TIME_MA.Items[1].Id, "01", "01");
            }
            else
            {
                var time_p_c = CL_TIME_MA.Items[0].Id.Split('-');
                if (time_p_c.Length == 2)
                {
                    int mul =
                        (FrequencyDominant == "M") ? 1 :
                        (FrequencyDominant == "Q") ? 3 :
                        (FrequencyDominant == "S") ? 6 : 0;

                    int t_fix = (int.Parse(time_p_c[1].Substring(1))) * mul;
                    time_min_normal = string.Format("{0}-{1}-{2}", time_p_c[0], (t_fix > 9) ? t_fix.ToString() : "0" + t_fix.ToString(), "01");
                    time_p_c = CL_TIME_MA.Items[1].Id.Split('-');
                    t_fix = (int.Parse(time_p_c[1].Substring(1))) * mul;
                    time_max_normal = string.Format("{0}-{1}-{2}", time_p_c[0], (t_fix > 9) ? t_fix.ToString() : "0" + t_fix.ToString(), "01");
                }
                if (CL_TIME_MA.Items[0].Id.Contains("S"))
                {
                    var time_p = CL_TIME_MA.Items[0].Id.Split('-');
                    int t_fix = (int.Parse(time_p[1].Substring(1))) * 6;
                    time_min_normal = string.Format("{0}-{1}-{2}", time_p[0], (t_fix > 9) ? t_fix.ToString() : "0" + t_fix.ToString(), "01");

                    time_p = CL_TIME_MA.Items[1].Id.Split('-');
                    t_fix = (int.Parse(time_p[1].Substring(1))) * 6;
                    time_max_normal = string.Format("{0}-{1}-{2}", time_p[0], (t_fix > 9) ? t_fix.ToString() : "0" + t_fix.ToString(), "01");
                }
                if (CL_TIME_MA.Items[0].Id.Contains("Q"))
                {
                    var time_p = CL_TIME_MA.Items[0].Id.Split('-');
                    int t_fix = ((int.Parse(time_p[1].Substring(1))) * 3);
                    time_min_normal = string.Format("{0}-{1}-{2}", time_p[0], (t_fix > 9) ? t_fix.ToString() : "0" + t_fix.ToString(), "01");

                    time_p = CL_TIME_MA.Items[1].Id.Split('-');
                    t_fix = ((int.Parse(time_p[1].Substring(1))) * 3);
                    time_max_normal = string.Format("{0}-{1}-{2}", time_p[0], (t_fix > 9) ? t_fix.ToString() : "0" + t_fix.ToString(), "01");
                }
                if (CL_TIME_MA.Items[0].Id.Contains("M"))
                {
                    var time_p = CL_TIME_MA.Items[0].Id.Split('-');
                    int t_fix = (int.Parse(time_p[1].Substring(1))) * 1;
                    time_min_normal = string.Format("{0}-{1}-{2}", time_p[0], (t_fix > 9) ? t_fix.ToString() : "0" + t_fix.ToString(), "01");

                    time_p = CL_TIME_MA.Items[1].Id.Split('-');
                    t_fix = (int.Parse(time_p[1].Substring(1))) * 1;
                    time_max_normal = string.Format("{0}-{1}-{2}", time_p[0], (t_fix > 9) ? t_fix.ToString() : "0" + t_fix.ToString(), "01");
                }
            }

               DateTime MinDate = DateTime.ParseExact(time_min_normal, "yyyy-MM-dd", CultureInfo.CurrentCulture, DateTimeStyles.None);
               DateTime MaxDate = DateTime.ParseExact(time_max_normal, "yyyy-MM-dd", CultureInfo.CurrentCulture, DateTimeStyles.None);
               //fabio baco
            //CultureInfo enEn = new CultureInfo("en");
            //DateTime MinDate = DateTime.ParseExact(time_min_normal, "yyyy-MM-dd", enEn, DateTimeStyles.None);
            //DateTime MaxDate = DateTime.ParseExact(time_max_normal, "yyyy-MM-dd", enEn, DateTimeStyles.None);

            ICodelistMutableObject CL_TIME = new CodelistMutableCore();
            CL_TIME.Id = CL_TIME_MA.Id;
            CL_TIME.AgencyId = CL_TIME_MA.AgencyId;
            CL_TIME.Version = CL_TIME_MA.Version;

            CL_TIME_MA.Names.ToList().ForEach(n => CL_TIME.AddName(n.Locale, n.Value));

            DateTime ActualDate = MinDate;
            switch (FrequencyDominant)
            {
                case "A":
                    #region Aggiungo gli Annual
                    while (ActualDate.CompareTo(MaxDate) <= 0)
                    {
                        ICodeMutableObject code = new CodeMutableCore();
                        code.Id = ActualDate.Year.ToString();
                        code.AddName("en", code.Id);
                        CL_TIME.AddItem(code);

                        ActualDate = ActualDate.AddYears(1);
                    }
                    #endregion
                    break;
                case "S":
                    #region Aggiungo gli Semestrali
                    while (ActualDate.CompareTo(MaxDate) <= 0)
                    {
                        ICodeMutableObject code = new CodeMutableCore();
                        code.Id = ActualDate.Year.ToString() + "-S" + (ActualDate.Month < 6 ? "1" : "2");
                        code.AddName("en", code.Id);
                        CL_TIME.AddItem(code);

                        ActualDate = ActualDate.AddMonths(6);
                    }
                    #endregion
                    break;
                case "Q":
                    #region Aggiungo i Quartely
                    while (ActualDate.CompareTo(MaxDate) <= 0)
                    {
                        ICodeMutableObject code = new CodeMutableCore();
                        code.Id = ActualDate.Year.ToString() + "-Q" + ((ActualDate.Month - 1) / 3 + 1).ToString();
                        code.AddName("en", code.Id);
                        CL_TIME.AddItem(code);

                        ActualDate = ActualDate.AddMonths(3);
                    }
                    #endregion
                    break;
                case "M":
                    #region Aggiungo i Mensili
                    while (ActualDate.CompareTo(MaxDate) <= 0)
                    {
                        ICodeMutableObject code = new CodeMutableCore();
                        code.Id = ActualDate.ToString("yyyy-MM");
                        code.AddName("en", code.Id);
                        CL_TIME.AddItem(code);

                        ActualDate = ActualDate.AddMonths(1);
                    }
                    #endregion
                    break;
                default:
                    break;
            }

            return CL_TIME.ImmutableInstance;
        }
コード例 #30
0
        /*
        /// <summary>
        /// Check if the specified <c>CodelistRefBean</c> is for the special COUNT request
        /// </summary>
        /// <param name="codelistRef">
        /// The <c>CodelistRefBean</c> object. It should have Id and Agency set. Version is ignored.
        /// </param>
        /// <returns>
        /// True if the  <c>CodelistRefBean</c> ID and Agency matches the custom <see cref="CountCodeList"/> and <see cref="Agency"/>. Else false
        /// </returns>
        public static bool IsCountRequest(CodelistRefBean codelistRef)
        {
            return CountCodeList.Equals(codelistRef.Id, StringComparison.InvariantCultureIgnoreCase)
                   && Agency.Equals(codelistRef.AgencyID, StringComparison.InvariantCultureIgnoreCase);
        }

        */
        /// <summary>
        /// Check if the specified <c>CodeListBean</c> is the special COUNT codelist
        /// </summary>
        /// <param name="codelist">
        /// The <c>CodeListBean</c> object. It should have Id and Agency set. Version is ignored.
        /// </param>
        /// <returns>
        /// True if the  <c>CodeListBean</c> ID and Agency matches the custom <see cref="CountCodeList"/> and <see cref="Agency"/>. Else false
        /// </returns>
        public static bool IsCountCodeList(ICodelistObject codelist)
        {
            return CountCodeList.Equals(codelist.Id, StringComparison.OrdinalIgnoreCase)
                   && Agency.Equals(codelist.AgencyId, StringComparison.OrdinalIgnoreCase)
                   && codelist.Items.Count == 1;
        }
コード例 #31
0
 /// <summary>
 /// Update the codelist cache with the specified codelist and component
 /// </summary>
 /// <param name="codelist">
 /// The codelist
 /// </param>
 /// <param name="component">
 /// The component
 /// </param>
 public void UpdateCodelistMap(ICodelistObject codelist, IComponent component)
 {
     this._codelistCache.Update(component, codelist);
     this._codeTreeMap[component] = new CodeTreeBuilder(codelist);
     if (component.HasCodedRepresentation() && !string.IsNullOrEmpty(component.Representation.Representation.MaintainableReference.MaintainableId))
     {
         this.BuildCodeDescriptionMap(component);
     }
 }