protected void btnLoginSubmit_Click(object sender, EventArgs e)
        {
            string myUserName = txtLoginUserName.Text.Trim();
            string myPassword = txtLoginPassword.Text.Trim();
            //string myEncriptedPassword = Utils.StringCryptography.Encrypt( myPassword );

            // Qui vengono recuperate le credenziali

            WSClient wsClient = new WSClient(IRConfiguration.GetEndPointByName(cmbEPoints.SelectedValue).IREndPoint);
            Service1SoapClient authClient = wsClient.GetClient();

            //Service1SoapClient authClient = new Service1SoapClient();

            //bool bb = authClient.CheckIfUserExists("pippo");

            User currentUser = authClient.GetUserByCredentials(myUserName, myPassword);
            if ( currentUser != null )
            {
                Session[SESSION_KEYS.USER_OK] = true;
                Session[SESSION_KEYS.USER_DATA] = currentUser;
                lblWelcomeUser.Visible = true;
                string userCompleteName = string.Format( "{0} {1}", currentUser.name.ToString(), currentUser.surname.ToString() );
                lblWelcomeUser.Text = string.Format( Resources.Messages.lblWelcomeUserMessagge, userCompleteName);
                loginButton.Visible = false;
                logoutButton.Visible = true;
                Response.Redirect(Request.RawUrl);
            }
            else
            {
                Utils.ShowDialog( "Le credenziali di accesso non sono corrette!" );
            }
        }
        protected void btnLoginSubmit_Click(object sender, EventArgs e)
        {
            string myUserName = txtLoginUserName.Text.Trim();
            string myPassword = txtLoginPassword.Text.Trim();
            // Qui vengono recuperate le credenziali

            EndPointElement epe = (EndPointElement)Session[SESSION_KEYS.CURRENT_ENDPOINT_OBJECT];

            User currentUser;

            if (epe.GetUsersFromFile)
            {
                currentUser = GetUserFromFile(myUserName, myPassword);
            }
            else
            {
                WSClient wsClient = new WSClient(epe.IREndPoint);
                IRService authClient = wsClient.GetClient();
                currentUser = authClient.GetUserByCredentials(myUserName, myPassword);
            }

            if (currentUser != null)
            {
                Session[SESSION_KEYS.USER_OK] = true;
                Session[SESSION_KEYS.USER_DATA] = currentUser;
                lblWelcomeUser.Visible = true;
                string userCompleteName = string.Format("{0} {1}", currentUser.name.ToString(), currentUser.surname.ToString());
                lblWelcomeUser.Text = string.Format(Resources.Messages.lblWelcomeUserMessagge, userCompleteName);
                loginButton.Visible = false;
                logoutButton.Visible = true;
                Response.Redirect(Request.RawUrl);
            }
            else
            {
                Utils.ShowDialog("Le credenziali di accesso non sono corrette!");
            }
        }
        protected void btnNewCodeOnFinalStructure_Click(object sender, EventArgs e)
        {
            string id = txt_id.Text;
            string agency = txtAgenciesReadOnly.Text;
            string[] tmpVersionParts = txt_version.Text.Split( '.' );
            bool[] versionsAvailable = {
                                           tmpVersionParts.Length > 0,
                                           tmpVersionParts.Length > 1,
                                           tmpVersionParts.Length > 2
                                       };
            int v1 = (versionsAvailable[0] ? Convert.ToInt32( tmpVersionParts[0] ) : 0 );
            int v2 = (versionsAvailable[1] ? Convert.ToInt32( tmpVersionParts[1] ) : 0 );
            int v3 = (versionsAvailable[2] ? Convert.ToInt32( tmpVersionParts[2] ) : 0 );

            EndPointElement epe = (EndPointElement)Session["CurrentEndPointObject"];
            WSClient wsClient = new WSClient(epe.IREndPoint);
            Service1SoapClient client = wsClient.GetClient();

            // Recupero l'id della codelist
            int foundCodelistId = 0, foundParentCodeId = 0, insertedCodeId = 0, foundLocalizedNameStringId = 0, foundLocalizedDescStringId = 0;
            client.GetCodelistId( id, agency, versionsAvailable[0], v1, versionsAvailable[1], v2, versionsAvailable[2], v3, ref foundCodelistId );

            string codeId = txt_id_new.Text.Trim(), parentCode = txt_parentid_new.Text.Trim(), codeOrder = txt_order_new.Text.Trim();

            #region CODE ID
            if ( !ValidationUtils.CheckIdFormat( codeId ) )
            {
                lblErrorOnNewInsert.Text = Resources.Messages.err_id_format;
                Utils.AppendScript( "openPopUp('df-Dimension', 600);" );
                Utils.AppendScript("location.href= '#codes';");
                return ;
            }

            #endregion

            #region CODE NAMES
            if ((AddTextName_new.TextObjectList == null) || (AddTextName_new.TextObjectList != null && AddTextName_new.TextObjectList.Count == 0 ) )
            {
                lblErrorOnNewInsert.Text = Resources.Messages.err_list_name_format;
                Utils.AppendScript( "openPopUp('df-Dimension', 600);" );
                Utils.AppendScript("location.href= '#codes';");
                return;
            }
            #endregion

            #region PARANT ID

            if ( codeId.Equals( parentCode ) )
            {
                lblErrorOnNewInsert.Text = Resources.Messages.err_parent_id_same_value;
                Utils.AppendScript( "openPopUp('df-Dimension-update', 600 );" );
                Utils.AppendScript("location.href= '#codes';");
                return;
            }

            #endregion

            #region CODE ORDER
            int tmpOrder = 0;
            if (!codeOrder.Equals(string.Empty) && !int.TryParse( codeOrder, out tmpOrder ) )
            {
                lblErrorOnNewInsert.Text = Resources.Messages.err_order_format_invalid;
                Utils.AppendScript( "openPopUp('df-Dimension', 600);" );
                Utils.AppendScript("location.href= '#codes';");
                return;
            }
            else
            {
                if ( tmpOrder < 0 )
                {
                    lblErrorOnNewInsert.Text = Resources.Messages.err_order_less_than_zero;
                    Utils.AppendScript( "openPopUp('df-Dimension', 600);" );
                    Utils.AppendScript("location.href= '#codes';");
                    return;
                }
            }
            #endregion

            if ( !client.GetDsdCodeId( foundCodelistId, parentCode, ref foundParentCodeId ) )
            {
                    lblErrorOnNewInsert.Text = Resources.Messages.err_while_retrieving_code;
                    Utils.AppendScript( "openPopUp('df-Dimension', 600);" );
                    Utils.AppendScript("location.href= '#codes';");
                    return;
            }

            if ( !client.InsertDsdCode( codeId, foundCodelistId.ToString(), foundParentCodeId, ref insertedCodeId ) )
            {
                    lblErrorOnNewInsert.Text = Resources.Messages.err_while_inserting_code;
                    Utils.AppendScript( "openPopUp('df-Dimension', 600);" );
                    Utils.AppendScript("location.href= '#codes';");
                    return;
            }
            if ( AddTextName_new.TextObjectList != null )
            {
                foreach ( var name in AddTextName_new.TextObjectList )
                {
                    if ( !client.InsertLocalizedString( insertedCodeId, name.Value, "Name", name.Locale, ref foundLocalizedNameStringId ) )
                    {
                        lblErrorOnNewInsert.Text = Resources.Messages.err_while_inserting_code_name;
                        Utils.AppendScript( "openPopUp('df-Dimension', 600);" );
                        Utils.AppendScript("location.href= '#codes';");
                        return;
                    }
                }
            }
            if ( AddTextDescription_new.TextObjectList != null )
            {
                foreach ( var desc in AddTextDescription_new.TextObjectList )
                {
                    if ( !client.InsertLocalizedString( insertedCodeId, desc.Value, "Desc", desc.Locale, ref foundLocalizedDescStringId ) )
                    {
                        lblErrorOnNewInsert.Text = Resources.Messages.err_while_inserting_code_desc;
                        Utils.AppendScript( "openPopUp('df-Dimension', 600);" );
                        Utils.AppendScript("location.href= '#codes';");
                        return;
                    }
                }
            }

            txt_id_new.Text = string.Empty;
            txt_parentid_new.Text = string.Empty;
            AddTextDescription_new.ClearTextObjectListWithOutJS();
            AddTextName_new.ClearTextObjectListWithOutJS();

            WSModel wsModel = new WSModel();
            ISdmxObjects sdmxObject = wsModel.GetCodeList(_artIdentity, false,false);
            ICodelistObject cl = sdmxObject.Codelists.FirstOrDefault();
            Session[KEY_PAGE_SESSION] = cl.MutableInstance;

            BindData();
            Utils.AppendScript("location.href= '#codes';");
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            if (cmbEPoints.SelectedIndex > 0)
            {
                WSClient wsClient;
                wsClient = new WSClient(IRConfiguration.GetEndPointByName(cmbEPoints.SelectedValue).IREndPoint);
                ssClient = wsClient.GetClient();
            }

            lblNewName.DataBind();
            lblNewPassword.DataBind();
            lblNewSurname.DataBind();
            lblNewUserName.DataBind();
            btnSaveNewUser.DataBind();
            if (!Page.IsPostBack)
            {
                Utils.PopulateCmbEndPoint(cmbEPoints);
                cmbEPoints.Items.Insert(0, "");
                Utils.PopulateCmbAgencySchemes(cmbAgencies);
                PopulateAgenciesGrid();
            }
        }