GetMessages() public method

Only called if language != en
public GetMessages ( ) : string>.Dictionary
return string>.Dictionary
コード例 #1
0
ファイル: Session.cs プロジェクト: ahazelwood/AWB
        /// <summary>
        /// Loads namespaces
        /// </summary>
        private void LoadProjectOptions()
        {
            string[] months = (string[])Variables.ENLangMonthNames.Clone();

            try
            {
                Site = new SiteInfo(Editor.SynchronousEditor);

                for (int i = 0; i < months.Length; i++)
                {
                    months[i] += "-gen";
                }
                Dictionary <string, string> messages = Site.GetMessages(months);

                if (messages.Count == 12)
                {
                    for (int i = 0; i < months.Length; i++)
                    {
                        months[i] = messages[months[i]];
                    }
                    Variables.MonthNames = months;
                }

                Variables.Namespaces       = Site.Namespaces;
                Variables.NamespaceAliases = Site.NamespaceAliases;
                Variables.MagicWords       = Site.MagicWords;
            }
            catch (ReadApiDeniedException)
            {
                throw;
            }
            catch (Exception ex)
            {
                //TODO:Better error handling

                string message = ex is WikiUrlException && ex.InnerException != null
                    ? ex.InnerException.Message
                    : ex.Message;

                MessageBox.Show("An error occured while connecting to the server or loading project information from it. " +
                                "Please make sure that your internet connection works and such combination of project/language exist." +
                                "\r\nEnter the URL in the format \"en.wikipedia.org/w/\" (including path where index.php and api.php reside)." +
                                "\r\nError description: " + message,
                                "Error connecting to wiki", MessageBoxButtons.OK, MessageBoxIcon.Error);

                throw;
            }
        }
コード例 #2
0
        /// <summary>
        /// Loads namespaces
        /// </summary>
        public static void LoadProjectOptions()
        {
            string[] months = (string[])ENLangMonthNames.Clone();

            try
            {
                SiteInfo si = new SiteInfo(URLLong, PHP5);

                for (int i = 0; i < months.Length; i++)
                {
                    months[i] += "-gen";
                }
                Dictionary <string, string> messages = si.GetMessages(months);

                if (messages.Count == 12)
                {
                    for (int i = 0; i < months.Length; i++)
                    {
                        months[i] = messages[months[i]];
                    }
                    MonthNames = months;
                }

                Namespaces       = si.Namespaces;
                NamespaceAliases = si.NamespaceAliases;
                MagicWords       = si.MagicWords;
            }
            catch (Exception ex)
            {
                string message = ex is WikiUrlException && ex.InnerException != null
                    ? ex.InnerException.Message
                    : ex.Message;

                MessageBox.Show("An error occured while connecting to the server or loading project information from it. " +
                                "Please make sure that your internet connection works and such combination of project/language exist." +
                                "\r\nEnter the URL in the format \"en.wikipedia.org/w/\" (including path where index.php and api.php reside)." +
                                "\r\nError description: " + message,
                                "Error connecting to wiki", MessageBoxButtons.OK, MessageBoxIcon.Error);
                SetDefaults();
                return;
            }
        }
コード例 #3
0
ファイル: Session.cs プロジェクト: svn2github/autowikibrowser
        /// <summary>
        /// Loads namespaces
        /// </summary>
        private void LoadProjectOptions()
        {
            string[] months = (string[])Variables.ENLangMonthNames.Clone();

            try
            {
                Site = new SiteInfo(Editor.SynchronousEditor);

                for (int i = 0; i < months.Length; i++)
                {
                    months[i] += "-gen";
                }
                Dictionary<string, string> messages = Site.GetMessages(months);

                if (messages.Count == 12)
                {
                    for (int i = 0; i < months.Length; i++)
                    {
                        months[i] = messages[months[i]];
                    }
                    Variables.MonthNames = months;
                }

                Variables.Namespaces = Site.Namespaces;
                Variables.NamespaceAliases = Site.NamespaceAliases;
                Variables.MagicWords = Site.MagicWords;
            }
            catch (ReadApiDeniedException)
            {
                throw;
            }
            catch (WebException ex)
            {
                string message = "";
                
                if (ex.InnerException != null)
                {
                    if (ex.InnerException is AuthenticationException)
                    {

                        if (message.Equals(""))
                        {
                            message = ex.Message;
                        }
                        else
                        {
                            message += " " + ex.Message;
                        }
                    }

                    if (message.Equals(""))
                    {
                        message = ex.InnerException.Message;
                    }
                    else
                    {
                        message += " " + ex.InnerException.Message;
                    }
                }
                else
                {
                    var resp = (HttpWebResponse)ex.Response;
                    if (resp == null) throw;

                    // Check for HTTP 401 error.
                    switch (resp.StatusCode)
                    {
                        case HttpStatusCode.Unauthorized: // 401
                            throw;
                    }
                    
                    message = ex.Message;
                }

                MessageBox.Show(message, "Error connecting to wiki", MessageBoxButtons.OK, MessageBoxIcon.Error);
                
                throw ex;
            }
            catch (Exception ex)
            {
                //TODO:Better error handling

                string message = "";

                if (ex is WikiUrlException)
                {
                    if (ex.InnerException != null)
                    {
                        message = ex.InnerException.Message;
                    }
                }
                else
                {
                    message = ex.Message;
                }

                MessageBox.Show("An error occured while connecting to the server or loading project information from it. " +
                        "Please make sure that your internet connection works and such combination of project/language exist." +
                        "\r\nEnter the URL in the format \"en.wikipedia.org/w/\" (including path where index.php and api.php reside)." +
                        "\r\nError description: " + message,
                        "Error connecting to wiki", MessageBoxButtons.OK, MessageBoxIcon.Error);

                throw;
            }
        }
コード例 #4
0
        /// <summary>
        /// Loads namespaces
        /// </summary>
        public static void LoadProjectOptions()
        {
            string[] months = (string[])ENLangMonthNames.Clone();

            try
            {
                SiteInfo si = new SiteInfo(URLLong, PHP5);

                for (int i = 0; i < months.Length; i++) months[i] += "-gen";
                Dictionary<string, string> messages = si.GetMessages(months);

                if (messages.Count == 12)
                {
                    for (int i = 0; i < months.Length; i++)
                    {
                        months[i] = messages[months[i]];
                    }
                    MonthNames = months;
                }

                Namespaces = si.Namespaces;
                NamespaceAliases = si.NamespaceAliases;
                MagicWords = si.MagicWords;
            }
            catch
            {
                MessageBox.Show("An error occured while connecting to the server or loading project information from it. " +
                        "Please make sure that your internet connection works and such combination of project/language exist." +
                        "\r\nEnter the URL in the format \"en.wikipedia.org/w/\" (including path where index.php and api.php reside).",
                        "Error connecting to wiki", MessageBoxButtons.OK, MessageBoxIcon.Error);
                SetDefaults();
                return;
            }
        }
コード例 #5
0
        /// <summary>
        /// Loads namespaces
        /// </summary>
        private void LoadProjectOptions()
        {
            string[] months = (string[])Variables.ENLangMonthNames.Clone();

            try
            {
                Site = new SiteInfo(Editor.SynchronousEditor);

                for (int i = 0; i < months.Length; i++)
                {
                    months[i] += "-gen";
                }

                // get localized month names if not en-wiki
                if (!Variables.IsWikipediaEN)
                {
                    Dictionary <string, string> messages = Site.GetMessages(months);

                    if (messages.Count == 12)
                    {
                        for (int i = 0; i < months.Length; i++)
                        {
                            months[i] = messages[months[i]];
                        }
                        Variables.MonthNames = months;
                    }
                }

                Variables.Namespaces       = Site.Namespaces;
                Variables.NamespaceAliases = Site.NamespaceAliases;
                Variables.MagicWords       = Site.MagicWords;
            }
            catch (ReadApiDeniedException)
            {
                throw;
            }
            catch (WebException ex)
            {
                string message = "";

                if (ex.InnerException != null)
                {
                    if (ex.InnerException is AuthenticationException)
                    {
                        if (message.Equals(""))
                        {
                            message = ex.Message;
                        }
                        else
                        {
                            message += " " + ex.Message;
                        }
                    }

                    if (message.Equals(""))
                    {
                        message = ex.InnerException.Message;
                    }
                    else
                    {
                        message += " " + ex.InnerException.Message;
                    }
                }
                else
                {
                    var resp = (HttpWebResponse)ex.Response;
                    if (resp == null)
                    {
                        throw;
                    }

                    // Check for HTTP 401 error.
                    switch (resp.StatusCode)
                    {
                    case HttpStatusCode.Unauthorized:     // 401
                        throw;
                    }

                    message = ex.Message;
                }

                MessageBox.Show(message, "Error connecting to wiki", MessageBoxButtons.OK, MessageBoxIcon.Error);

                throw;
            }
            catch (Exception ex)
            {
                // TODO:Better error handling

                string message = "";

                if (ex is WikiUrlException)
                {
                    if (ex.InnerException != null)
                    {
                        message = ex.InnerException.Message;
                    }
                }
                else
                {
                    message = ex.Message;
                }

                MessageBox.Show("An error occured while connecting to the server or loading project information from it. " +
                                "Please make sure that your internet connection works and such combination of project/language exist." +
                                "\r\nEnter the URL in the format \"en.wikipedia.org/w/\" (including path where index.php and api.php reside)." +
                                "\r\nError description: " + message,
                                "Error connecting to wiki", MessageBoxButtons.OK, MessageBoxIcon.Error);

                throw;
            }
        }
コード例 #6
0
        /// <summary>
        /// Loads namespaces
        /// </summary>
        public static void LoadProjectOptions()
        {
            string[] months = (string[])ENLangMonthNames.Clone();

            try
            {
                SiteInfo si = new SiteInfo(URLLong);

                for (int i = 0; i < months.Length; i++) months[i] += "-gen";
                Dictionary<string, string> messages = si.GetMessages(months);

                if (messages.Count == 12)
                {
                    for (int i = 0; i < months.Length; i++)
                    {
                        months[i] = messages[months[i]];
                    }
                    MonthNames = months;
                }

                Namespaces = si.Namespaces;
            }
            catch
            {
                if (MessageBox.Show(@"An error occured while loading project information from the server.
Do you want to use default settings?", "Error loading namespaces", MessageBoxButtons.YesNo) == DialogResult.Yes)
                {
                    Namespaces = enLangNamespaces;
                    MonthNames = (string[])ENLangMonthNames.Clone();
                    return;
                }
                else if (!string.IsNullOrEmpty(CustomProject))
                {
                    MessageBox.Show("An error occured while loading project information from the server. " +
                        "Please make sure that your internet connection works and such combination of project/language exist." +
                        "\r\nEnter the URL of the index.php file in the format \"en.wikipedia.org/w/\"",
                        "Error loading namespaces", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    SetDefaults();
                }
                MessageBox.Show("Defaulting to the English Wikipedia settings.", "Project options",
                    MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }
        }
コード例 #7
0
ファイル: Session.cs プロジェクト: svn2github/autowikibrowser
        /// <summary>
        /// Loads namespaces
        /// </summary>
        private void LoadProjectOptions()
        {
            string[] months = (string[])Variables.ENLangMonthNames.Clone();

            try
            {
                Site = new SiteInfo(Editor.SynchronousEditor);

                for (int i = 0; i < months.Length; i++) months[i] += "-gen";
                Dictionary<string, string> messages = Site.GetMessages(months);

                if (messages.Count == 12)
                {
                    for (int i = 0; i < months.Length; i++)
                    {
                        months[i] = messages[months[i]];
                    }
                    Variables.MonthNames = months;
                }

                Variables.Namespaces = Site.Namespaces;
                Variables.NamespaceAliases = Site.NamespaceAliases;
                Variables.MagicWords = Site.MagicWords;
            }
            catch (Exception ex)
            {
                //TODO:Better error handling

                string message = ex is WikiUrlException && ex.InnerException != null 
                    ? ex.InnerException.Message
                    : ex.Message;

                MessageBox.Show("An error occured while connecting to the server or loading project information from it. " +
                        "Please make sure that your internet connection works and such combination of project/language exist." +
                        "\r\nEnter the URL in the format \"en.wikipedia.org/w/\" (including path where index.php and api.php reside)." +
                        "\r\nError description: " + message,
                        "Error connecting to wiki", MessageBoxButtons.OK, MessageBoxIcon.Error);

                throw;
            }
        }