private IDataProviderSchemeMutableObject GetDataProviderschemeForm(IDataProviderSchemeMutableObject dataProviderScheme)
        {
            if (dataProviderScheme == null) return GetDataProviderschemeForm();

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

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

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

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

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

            #region DATAPROVIDERSCHEME 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 DATAPROVIDERSCHEME START END DATE
            bool checkForDatesCombination = true;

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

            if (!txtValidTo.Text.Trim().Equals(string.Empty) && !ValidationUtils.CheckDateFormat(txtValidTo.Text))
            {
                messagesGroup += Convert.ToString(errorCounter) + ")" + Resources.Messages.err_date_to_format + "<br /><br />";
                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) + ")" + Resources.Messages.err_date_diff + "<br /><br />";
                        errorCounter++;
                        isInError = true;
                    }
                }
            }
            #endregion

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

            #region CREATE DATAPROVIDERSCHEME FROM FORM

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

            if (dataProviderScheme.Annotations.Count != 0)
            {
                dataProviderScheme.Annotations.Clear();
            }
            if (AnnotationGeneralControl.AnnotationObjectList != null)
                foreach (var annotation in AnnotationGeneralControl.AnnotationObjectList)
                {
                    dataProviderScheme.AddAnnotation(annotation);
                }

            #endregion

            return dataProviderScheme;
        }
        private bool SaveInMemory(IDataProviderSchemeMutableObject dataProviderScheme)
        {
            if (dataProviderScheme == null) return false;

            Session[KEY_PAGE_SESSION] = dataProviderScheme;

            return true;
        }
        private bool SendQuerySubmit(IDataProviderSchemeMutableObject dataProviderScheme)
        {
            try
            {

                ISdmxObjects sdmxObjects = new SdmxObjectsImpl();

                sdmxObjects.AddDataProviderScheme(dataProviderScheme.ImmutableInstance);

                WSModel modelDataProviderScheme = new WSModel();

                XmlDocument result = modelDataProviderScheme.SubmitStructure(sdmxObjects);

                Utils.GetXMLResponseError(result);

                return true;

            }
            catch (Exception ex)
            {
                return false;
            }
        }
        private IDataProviderSchemeMutableObject InsertDataProviderInDataProviderscheme(IDataProviderSchemeMutableObject dataProviderScheme)
        {
            if (dataProviderScheme == null) return null;

            IDataProviderMutableObject dataProvider = new DataProviderMutableCore();

            string data_provider_id = txt_id_new.Text.Trim();

            IList<ITextTypeWrapperMutableObject> data_provider_names = AddTextName_new.TextObjectList;
            IList<ITextTypeWrapperMutableObject> data_provider_descs = AddTextDescription_new.TextObjectList;
            // string code_order_str = txtOrderNewCode.Text.Trim();     ----- ORDINE

            #region DATAPROVIDER ID
            if (ValidationUtils.CheckIdFormat(data_provider_id))
            {
                dataProvider.Id = data_provider_id;
            }
            else
            {
                lblErrorOnNewInsert.Text = Resources.Messages.err_id_format;
                Utils.AppendScript( "openPopUp('df-Dimension', 600);" );
                Utils.AppendScript("location.href= '#dataproviders';");
                return null;
            }

            IEnumerable<IDataProviderMutableObject> dataProviders = (from c in dataProviderScheme.Items where c.Id == data_provider_id select c).OfType<IDataProviderMutableObject>();
            if (dataProviders.Count() > 0)
            {
                lblErrorOnNewInsert.Text = Resources.Messages.err_id_exist;
                Utils.AppendScript( "openPopUp('df-Dimension', 600);" );
                Utils.AppendScript("location.href= '#dataproviders';");
                return null;
            }
            #endregion

            #region DATAPROVIDER NAMES
            if (data_provider_names != null)
            {
                foreach (var tmpName in data_provider_names)
                {
                    dataProvider.AddName(tmpName.Locale, tmpName.Value);
                }
            }
            else
            {
                lblErrorOnNewInsert.Text = Resources.Messages.err_list_name_format;
                Utils.AppendScript( "openPopUp('df-Dimension', 600);" );
                Utils.AppendScript("location.href= '#dataproviders';");
                return null;
            }
            #endregion

            #region DATAPROVIDER DESCRIPTIONS
            if (data_provider_descs != null)
            {
                foreach (var tmpDescription in data_provider_descs)
                {
                    dataProvider.AddDescription(tmpDescription.Locale, tmpDescription.Value);
                }
            }
            #endregion

            dataProviderScheme.Items.Add(dataProvider);

            try
            {
                // Ultimo controllo se ottengo Immutable istanze validazione completa
                var canRead = dataProviderScheme.ImmutableInstance;
            }
            catch (Exception ex)
            {
                dataProviderScheme.Items.Remove(dataProvider);

                return null;

            }
            return dataProviderScheme;
        }