Ejemplo n.º 1
0
        /// <summary>
        /// Checks if the Login form must be showed or not.
        /// This is calculated according the number of agents defined in the View,
        /// its kind (anonymous or not), and the number of languages of the application.
        /// </summary>
        /// <returns>A boolean value indicating if the Login form is going to be shown or not.</returns>
        private bool CheckIsAnonymousAndLogIn()
        {
            bool lResult = false;

            if (Logics.Agents.All.Length == 1)
            {
                // Create agent info.
                string         lAgentClassName = Logics.Agents.All[0].ToString();
                Oids.Oid       lagent          = Oids.Oid.Create(lAgentClassName);
                Oids.AgentInfo lAgentInfo      = lagent as Oids.AgentInfo;

                if (lAgentInfo is Oids.AnonymousAgentInfo)
                {
                    if (CultureManager.SupportedLanguages.Count > 1)
                    {
                        // Apply Change Language menu entry.
                        this.mValidateAgent.Text = CultureManager.TranslateString(LanguageConstantKeys.L_MAIN_CHANGE_LANGUAGE, LanguageConstantValues.L_MAIN_CHANGE_LANGUAGE);
                        // Login form will be showed, because there are more than one language.
                        lResult = false;
                    }
                    else
                    {
                        // Hide Login and Change Password menu entries.
                        this.mValidateAgent.Visible = false;

                        // Login form will not be showed, because the unique agent is anonymous.
                        // and there is only one language.
                        lResult = true;

                        // Assign the unique language supported.
                        foreach (System.Globalization.CultureInfo cultureInfo in CultureManager.SupportedLanguages.Values)
                        {
                            CultureManager.Culture = cultureInfo;
                        }
                    }

                    // Show anonymous agent alias.
                    StringBuilder lStringBuilder = new StringBuilder();
                    lStringBuilder.Append(CultureManager.TranslateString(lAgentInfo.IdXML + "_Alias", UtilFunctions.ProtectAmpersandChars(lAgentInfo.Alias)));
                    toolStripStatusLabel.Text = lStringBuilder.ToString();
                    // Show Current culture.
                    toolStripStatusLabelCulture.Text = CultureManager.Culture.Name;

                    // Hide Change Password menu entry.
                    this.mChangePassword.Visible = false;
                }
                else
                {
                    // Login form will be showed, because the agent is not anonymous.
                    lResult = false;
                }
            }

            // Result return.
            return(lResult);
        }
Ejemplo n.º 2
0
 /// <summary>
 /// Initializes a new instance of Request.
 /// </summary>
 /// <param name="agent">Agent.</param>
 public Request(Oids.AgentInfo agent)
 {
     this.Agent = agent;
 }