コード例 #1
0
        /// <summary>
        /// Create a ImmutableInstance of CategoryScheme
        /// </summary>
        /// <param name="CategoryObjects">List of CategoryObject</param>
        /// <returns>ICategorySchemeObject</returns>
        public ICategorySchemeObject BuildCategorySchemeObject(List <ICategoryMutableObject> CategoryObjects)
        {
            try
            {
                ICategorySchemeMutableObject ca = new CategorySchemeMutableCore();
                ca.AgencyId = this.CategorySchemeAgencyId;
                ca.Id       = this.Code;
                ca.Version  = this.categorySchemeVersion;
                foreach (SdmxObjectNameDescription item in this.Names)
                {
                    ca.AddName(item.Lingua, item.Name);
                }

                //IAnnotationMutableObject ann = new AnnotationMutableCore();
                //ann.Type = "CategoryScheme_node_order";
                //ann.Text.Add(new TextTypeWrapperMutableCore("en", "0"));
                //ca.AddAnnotation(ann);

                if (!this.ParsingObject.ReturnStub)
                {
                    foreach (ICategoryMutableObject item in CategoryObjects)
                    {
                        ca.AddItem(item);
                    }

                    ca.FinalStructure = TertiaryBool.ParseBoolean(true);
                }

                if (this.ParsingObject.isReferenceOf || this.ParsingObject.ReturnStub)
                {
                    ca.ExternalReference = TertiaryBool.ParseBoolean(true);
                    ca.StructureURL      = RetreivalStructureUrl.Get(this, ca.Id, ca.AgencyId, ca.Version);
                }

                return(ca.ImmutableInstance);
            }
            catch (SdmxException) { throw; }
            catch (Exception ex)
            {
                throw new SdmxException(this, FlyExceptionObject.FlyExceptionTypeEnum.CreateImmutable, ex);
            }
        }
        private ICategorySchemeMutableObject GetCategoryschemeForm()
        {
            bool isInError = false;                 // Indicatore di errore
            string messagesGroup = string.Empty;    // Stringa di raggruppamento errori
            int errorCounter = 1;                   // Contatore errori

            #region CATEGORYSCHEME ID
            if (!ValidationUtils.CheckIdFormat(txtDSDID.Text))
            {
                messagesGroup += Convert.ToString(errorCounter) + string.Format(") {0}<br /><br />", Resources.Messages.err_id_format);
                errorCounter++;
                isInError = true;
            }
            #endregion

            #region CATEGORYSCHEME AGENCY
            if (cmbAgencies.Text.Trim().Equals(string.Empty))
            {
                messagesGroup += Convert.ToString(errorCounter) + ") " + Resources.Messages.err_agency_missing + "<br /><br />";
                errorCounter++;
                isInError = true;
            }
            #endregion

            #region CATEGORYSCHEME VERSION
            if (!ValidationUtils.CheckVersionFormat(txtVersion.Text))
            {
                messagesGroup += Convert.ToString(errorCounter) + string.Format(") {0}<br /><br />", Resources.Messages.err_version_format);
                errorCounter++;
                isInError = true;
            }
            #endregion

            /* URI NOT REQUIRED */
            #region CATEGORYSCHEME URI
            if ((txtDSDURI.Text != string.Empty) && !ValidationUtils.CheckUriFormat(txtDSDURI.Text))
            {
                messagesGroup += Convert.ToString(errorCounter) + string.Format(") {0}<br /><br />", Resources.Messages.err_uri_format);
                errorCounter++;
                isInError = true;
            }
            #endregion

            #region CATEGORYSCHEME NAMES
            if (AddTextName.TextObjectList == null || AddTextName.TextObjectList.Count == 0)
            {
                messagesGroup += Convert.ToString(errorCounter) + string.Format(") {0}<br /><br />", Resources.Messages.err_list_name_format);
                errorCounter++;
                isInError = true;
            }
            #endregion

            #region CATEGORYSCHEME START END DATE
            bool checkForDatesCombination = true;

            if (!txtValidFrom.Text.Trim().Equals(string.Empty) && !ValidationUtils.CheckDateFormat(txtValidFrom.Text))
            {
                messagesGroup += Convert.ToString(errorCounter) + string.Format(") {0}<br /><br />", Resources.Messages.err_date_from_format);
                errorCounter++;
                checkForDatesCombination = false;
                isInError = true;
            }

            if (!txtValidTo.Text.Trim().Equals(string.Empty) && !ValidationUtils.CheckDateFormat(txtValidTo.Text))
            {
                messagesGroup += Convert.ToString(errorCounter) + string.Format(") {0}<br /><br />", Resources.Messages.err_date_to_format);
                errorCounter++;
                checkForDatesCombination = false;
                isInError = true;
            }

            if (!txtValidFrom.Text.Trim().Equals(string.Empty) && !txtValidTo.Text.Trim().Equals(string.Empty))
            {
                // Controllo congruenza date
                if (checkForDatesCombination)
                {
                    if (!ValidationUtils.CheckDates(txtValidFrom.Text, txtValidTo.Text))
                    {
                        messagesGroup += Convert.ToString(errorCounter) + string.Format(") {0}<br /><br />", Resources.Messages.err_date_diff);
                        errorCounter++;
                        isInError = true;
                    }
                }
            }
            #endregion

            if (isInError)
            {
                Utils.ShowDialog(messagesGroup, 300);
                return null;
            }

            ICategorySchemeMutableObject tmpCategoryscheme = new CategorySchemeMutableCore();
            #region CREATE CATEGORY FROM FORM

            tmpCategoryscheme.AgencyId = GetAgencyValue();
            tmpCategoryscheme.Id = txtDSDID.Text;
            tmpCategoryscheme.Version = txtVersion.Text;
            tmpCategoryscheme.FinalStructure = TertiaryBool.ParseBoolean(chkIsFinal.Checked);
            tmpCategoryscheme.Uri = (!txtDSDURI.Text.Trim().Equals(string.Empty) && ValidationUtils.CheckUriFormat(txtDSDURI.Text)) ? new Uri(txtDSDURI.Text) : null;
            if (!txtValidFrom.Text.Trim().Equals(string.Empty))
            {
                tmpCategoryscheme.StartDate = DateTime.ParseExact(txtValidFrom.Text, "dd/MM/yyyy", CultureInfo.InvariantCulture);
            }
            if (!txtValidTo.Text.Trim().Equals(string.Empty))
            {
                tmpCategoryscheme.EndDate = DateTime.ParseExact(txtValidTo.Text, "dd/MM/yyyy", CultureInfo.InvariantCulture);
            }
            foreach (var tmpName in AddTextName.TextObjectList)
            {
                tmpCategoryscheme.AddName(tmpName.Locale, tmpName.Value);
            }
            if (AddTextDescription.TextObjectList != null)
                foreach (var tmpDescription in AddTextDescription.TextObjectList)
                {
                    tmpCategoryscheme.AddDescription(tmpDescription.Locale, tmpDescription.Value);
                }
            if (AnnotationGeneralControl.AnnotationObjectList != null)
                foreach (var tmpAnnotation in AnnotationGeneralControl.AnnotationObjectList)
                {
                    tmpCategoryscheme.AddAnnotation(tmpAnnotation);
                }
            #endregion

            return tmpCategoryscheme;
        }
        /// <summary>
        /// Handles the Structure top level elements
        ///     This includes Codelist
        /// </summary>
        /// <param name="parent">
        /// The parent <see cref="IMutableObjects"/>
        /// </param>
        /// <param name="localName">
        /// The name of the current xml element
        /// </param>
        /// <returns>
        /// The <see cref="StructureReaderBaseV20.ElementActions"/>.
        /// </returns>
        protected override ElementActions HandleTopLevel(IMutableObjects parent, object localName)
        {
            ElementActions actions = null;
            if (NameTableCache.IsElement(localName, ElementNameTable.CategoryScheme))
            {
                var cs = new CategorySchemeMutableCore();
                ParseAttributes(cs, this.Attributes);
                parent.AddCategoryScheme(cs);
                this._currentCategoryScheme = cs;
                actions = this.AddNameableAction(cs, this.HandleChildElements);
            }

            return actions;
        }
コード例 #4
0
        private void GetAllCategoryInformation()
        {
            try
            {
                //Devo popolare tutte e due le referenze (Category Categorisation)
                //DataflowsManager dfMan = new DataflowsManager(this.parsingObject.CloneForReferences(), this.versionTypeResp);
                //List<MSDataflow> DFs = dfMan.GetMSDataflows(new BuilderParameter() { });

                //sdmxObjContainer = new SdmxObjectsImpl();

                _dtCSFull = DbAccess.ExecutetoTable(DBOperationEnum.GetCategorySchemes, null);

                if (_dtCSFull.Rows.Count <= 0)
                {
                    return;
                }

                ReferencesObject.CategoryScheme = new List <ICategorySchemeObject>();

                List <ICategorySchemeObject> lCS = new List <ICategorySchemeObject>();
                DataView  viewCS = new DataView(_dtCSFull);
                DataTable dtCS   = viewCS.ToTable(true, "IDCS", "CSID", "CSAgency", "CSVersion");

                ICategorySchemeMutableObject catSchema = null;

                string filter;

                foreach (DataRow cs in dtCS.Rows)
                {
                    catSchema          = new CategorySchemeMutableCore();
                    catSchema.Id       = cs["CSID"].ToString();
                    catSchema.AgencyId = cs["CSAgency"].ToString();
                    catSchema.Version  = cs["CSVersion"].ToString();

                    // Get Names
                    DataTable dtCSNames = viewCS.ToTable(true, "IDCS", "CSLangName", "CSValueName");
                    filter = String.Format("IDCS = {0}", cs["IDCS"].ToString());
                    SetNames(dtCSNames.Select(filter), catSchema);

                    AddChilds(catSchema, filter);

                    ReferencesObject.CategoryScheme.Add(catSchema.ImmutableInstance);
                }

                GetCategorisationDataflow();

                //ICategoryMutableObject catO;
                //List<ICategoryMutableObject> lCatO = null;

                //catO = new CategoryMutableCore();

                //catO.AddName("nome", "en");
                //catO.Id = row["CatCode"].ToString();


                //    lCatO.Add(catO);


                //                    lCatO = new List<ICategoryMutableObject>();

                //            csb.Code = row["ID"].ToString();
                //            csb.CategorySchemeAgencyId = row["Agency"].ToString();
                //            csb.CategorySchemeVersion = row["Version"].ToString();

                //            csb.Names.Add(new SdmxObjectNameDescription() { Name = "nome", Lingua = "en" });

                //            idCS = currIDCS;

                //ReferencesObject.CategoryScheme.Add(csb.BuildCategorySchemeObject(lCatO));

                //csb.Names = SdmxObjectNameDescription.GetNameDescriptions(CategorySchemeNode);

                //ReferencesObject.CategoryScheme.Add(csb.BuildCategorySchemeObject(CategoryObjects));


                //this.ReferencesObject.CategoryScheme = new List<ICategorySchemeObject>();
                //this.ReferencesObject.Categorisation = new List<ICategorisationObject>();
                //foreach (XmlNode CategorySchemeNode in CategorySchemeList)
                //{
                //    csb.Code = CategorySchemeNode.Attributes["Code"].Value.ToString();
                //    csb.CategorySchemeAgencyId = CategorySchemeNode.Attributes["AgencyId"].Value;
                //    csb.CategorySchemeVersion = CategorySchemeNode.Attributes["Version"].Value;
                //    csb.Names = SdmxObjectNameDescription.GetNameDescriptions(CategorySchemeNode);
                //    List<ICategoryMutableObject> CategoryObjects = RecursivePopulateTreeCategorySP(CategorySchemeNode.ChildNodes, DFs, new List<string>());
                //    this.ReferencesObject.CategoryScheme.Add(csb.BuildCategorySchemeObject(CategoryObjects));
                //}
            }
            catch (SdmxException sEx)
            {
                throw sEx;
            }
            catch (Exception ex)
            {
                throw new SdmxException(this, FlyExceptionObject.FlyExceptionTypeEnum.InternalError, ex);
            }
        }