Ejemplo n.º 1
0
 /// <summary>
 /// Add references to <paramref name="structureReferences"/>
 /// </summary>
 /// <param name="categorisation">
 /// The categorisation.
 /// </param>
 /// <param name="structureReferences">
 /// The structure references.
 /// </param>
 private static void AddReferences(ICategorisationMutableObject categorisation, ISet <IStructureReference> structureReferences)
 {
     if (categorisation != null && !categorisation.Stub)
     {
         structureReferences.Add(categorisation.CategoryReference);
         structureReferences.Add(categorisation.StructureReference);
     }
 }
        private bool SaveInMemory(ICategorisationMutableObject cat)
        {
            if (cat == null) return false;

            Session[KEY_PAGE_SESSION] = cat;

            return true;
        }
        private bool SendQuerySubmit(ICategorisationMutableObject cat)
        {
            try
            {

                ISdmxObjects sdmxObjects = new SdmxObjectsImpl();

                /* int indexOrder = 1;
                 foreach (ICodeMutableObject code in cl.Items)
                 {
                     IEnumerable<IAnnotationMutableObject> annotations = (from a in code.Annotations where a.Type == "@ORDER@" select a).OfType<IAnnotationMutableObject>();
                     IAnnotationMutableObject annotation = (annotations.Count() > 0) ? annotations.First() : GetAnnotationOrder(indexOrder++);
                     code.AddAnnotation(annotation);

                     lblCodeListDetail.Text = code.Names[0].Value ;

                 }*/

                sdmxObjects.AddCategorisation(cat.ImmutableInstance);

                WSModel modelCategorization = new WSModel();

                XmlDocument result = modelCategorization.SubmitStructure(sdmxObjects);

                if (Utils.GetXMLResponseError(result) != "")
                {
                    Utils.ShowDialog(Utils.GetXMLResponseError(result), 350, "Error");
                    return false;
                }

                return true;

            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        private ICategorisationMutableObject GetCategorizationForm(ICategorisationMutableObject cat)
        {
            if (cat == null) return GetCategorizationForm();

            bool isInError = false;                 // Indicatore di errore
            string messagesGroup = string.Empty;    // Stringa di raggruppamento errori
            int errorCounter = 1;                   // Contatore errori

            #region CATEGORIZATION ID
            if (!ValidationUtils.CheckIdFormat(txt_id.Text.Trim()))
            {
                messagesGroup += Convert.ToString(errorCounter) + ") " + Resources.Messages.err_id_format + "<br /><br />";
                errorCounter++;
                isInError = true;
            }
            #endregion

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

            #region CATEGORIZATION VERSION
            if (!ValidationUtils.CheckVersionFormat(txt_version.Text.Trim()))
            {
                messagesGroup += Convert.ToString(errorCounter) + ") " + Resources.Messages.err_version_format + "<br /><br />";
                errorCounter++;
                isInError = true;
            }
            #endregion

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

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

            #region CATEGORIZATION START END DATE
            bool checkForDatesCombination = true;

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

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

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

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

            #region CREATE CODELIST FROM FORM

            cat.AgencyId = GetAgencyValue();
            cat.Id = txt_id.Text;
            cat.Version = txt_version.Text;
            cat.FinalStructure = TertiaryBool.ParseBoolean(chk_isFinal.Checked);
            cat.Uri = (!txt_uri.Text.Trim().Equals(string.Empty) && ValidationUtils.CheckUriFormat(txt_uri.Text)) ? new Uri(txt_uri.Text) : null;
            if (!txt_valid_from.Text.Trim().Equals(string.Empty))
            {
                cat.StartDate = DateTime.ParseExact(txt_valid_from.Text, "dd/MM/yyyy", CultureInfo.InvariantCulture);
            }
            if (!txt_valid_to.Text.Trim().Equals(string.Empty))
            {
                cat.EndDate = DateTime.ParseExact(txt_valid_to.Text, "dd/MM/yyyy", CultureInfo.InvariantCulture);
            }
            if (cat.Names.Count != 0)
            {
                cat.Names.Clear();
            }
            foreach (var tmpName in AddTextName.TextObjectList)
            {
                cat.AddName(tmpName.Locale, tmpName.Value);
            }
            if (cat.Descriptions.Count != 0)
            {
                cat.Descriptions.Clear();
            }
            if (AddTextDescription.TextObjectList != null)
                foreach (var tmpDescription in AddTextDescription.TextObjectList)
                {
                    cat.AddDescription(tmpDescription.Locale, tmpDescription.Value);
                }
            if (cat.Annotations.Count != 0)
            {
                cat.Annotations.Clear();
            }
            if (AnnotationGeneralControl.AnnotationObjectList != null)
                foreach (var annotation in AnnotationGeneralControl.AnnotationObjectList)
                {
                    cat.AddAnnotation(annotation);
                }

            #endregion

            string kindOfStructure = Session["tmpKindOfStructure"].ToString();
            SdmxStructureEnumType typeOfTheStructure = default(SdmxStructureEnumType);

            switch (kindOfStructure)
            {
                case "CODELIST":
                    typeOfTheStructure = SdmxStructureEnumType.CodeList;
                    break;
                case "CONCEPT_SCHEME":
                    typeOfTheStructure = SdmxStructureEnumType.ConceptScheme;
                    break;
                case "CATEGORY_SCHEME":
                    typeOfTheStructure = SdmxStructureEnumType.CategoryScheme;
                    break;
                case "DATAFLOW":
                    typeOfTheStructure = SdmxStructureEnumType.Dataflow;
                    break;
                case "AGENCY_SCHEME":
                    typeOfTheStructure = SdmxStructureEnumType.AgencyScheme;
                    break;
                case "DATA_PROVIDER_SCHEME":
                    typeOfTheStructure = SdmxStructureEnumType.DataProviderScheme;
                    break;
                case "DATA_CONSUMER_SCHEME":
                    typeOfTheStructure = SdmxStructureEnumType.DataConsumerScheme;
                    break;
                case "ORGANIZATION_UNIT_SCHEME":
                    typeOfTheStructure = SdmxStructureEnumType.OrganisationUnitScheme;
                    break;
                case "STRUCTURE_SET":
                    typeOfTheStructure = SdmxStructureEnumType.StructureSet;
                    break;
                case "CONTENT_CONSTRAINT":
                    typeOfTheStructure = SdmxStructureEnumType.ContentConstraint;
                    break;
                case "KEY_FAMILY":
                    typeOfTheStructure = SdmxStructureEnumType.Dsd;
                    break;
            }

            string referenceOfTheObject = Session["tmpReferenceOfTheObject"].ToString();
            string[] elementsOfTheReference = referenceOfTheObject.Split('-');

            IStructureReference structureRef = new StructureReferenceImpl(elementsOfTheReference[1], elementsOfTheReference[0], elementsOfTheReference[2], typeOfTheStructure);
            cat.StructureReference = structureRef;

            string[] referenceOfTheCategory = { Session["tmpCategoryReference"].ToString() };
            string referenceOfTheCategoryScheme = Session["tmpCategorySchemeReference"].ToString();
            string[] elementsOfTheCategoryScheme = referenceOfTheCategoryScheme.Split('-');
            IStructureReference categoryRef = new StructureReferenceImpl(elementsOfTheCategoryScheme[1], elementsOfTheCategoryScheme[0], elementsOfTheCategoryScheme[2], SdmxStructureEnumType.Category, referenceOfTheCategory);
            cat.CategoryReference = categoryRef;

            return cat;
        }