コード例 #1
0
        // Public Methods 

        public static string GetStatusDescription(WellKownCpanelProblems status, string df = null)
        {
            // "Brak dostępu do CPanela, prawdopodobnie zła nazwa użytkownika lub hasło"
            switch (status)
            {
            case WellKownCpanelProblems.LoginError:
                return(Polish.strBladLogowaniaDoCPanel + " " + Polish.strSprawdzNazweUzytkownikaIHaslo);

            case WellKownCpanelProblems.NameResolutionFailure:
                return(Polish.strNieZnalezionoSerweraCPanel);

            case WellKownCpanelProblems.EmptyOrInvalidCPanelURL:
                return(Polish.strAdresCPanelaJestPustyLubNieZawieraPrawidlowegoAdresuURLDlaProtokoluHttpLubHttps);

            case WellKownCpanelProblems.EmptyUsernameOrPassword:
                return(Polish.strBrakNazwyUzytkownikaLubHaslaDoCPanela);

            default:
                return(string.IsNullOrEmpty(df) ? Polish.strInnyBlad : df);
            }
        }
コード例 #2
0
ファイル: BasicApi.cs プロジェクト: tablesmit/sharppanel
        public string InterpreteException(Exception e, out WellKownCpanelProblems problem)
        {
            problem = WellKownCpanelProblems.Unknown;
            if (e is CPanelException)
            {
                problem = (e as CPanelException).Status;
                return(e.Message);
            }
            else if (e is WebException)
            {
                WebException we = e as WebException;
                switch (we.Status)
                {
                case WebExceptionStatus.ProtocolError:
                    HttpWebResponse wr = we.Response as HttpWebResponse;
                    if (wr != null)
                    {
                        if (wr.StatusCode == HttpStatusCode.Forbidden)
                        {
                            problem = WellKownCpanelProblems.LoginError;
                            return(CPanelException.GetStatusDescription(problem));
                        }
                        return(string.Format(Polish.strBladProtokoluHTTP, wr.StatusCode));
                    }
                    return(Polish.strInnyBladProtokoluHTTP);

                case WebExceptionStatus.NameResolutionFailure:
                    string hostName = "";
                    try
                    {
                        Uri u = new Uri(this.uRL);
                        hostName = u.Host;
                    }
                    catch { }
                    return(string.Format(Polish.strNieMoznaZnalezcSerwera0 + " " + Polish.strSprawdzNazweSerweraOrazPolaczenieZInternetem, hostName));

                case WebExceptionStatus.ConnectFailure:
                    return(string.Format(Polish.strNieMoznaPodlaczycSieDoCPanela0 + " " + Polish.strSprawdzPoprawnoscAdresuOrazPolaczenieZInternetem, uRL));

                case WebExceptionStatus.Timeout:
                    return(Polish.strSerwerNieOdpowiedzialWOczekiwanymCzasie + " " + Polish.strMozeToBycWinaSerweraLubProblemZPolaczeniemDoInternetu);

                default:
                    return(string.Format(Polish.strBladSieciowy0, we.Status));
                }
            }
            if (e is System.Net.Sockets.SocketException)
            {
                System.Net.Sockets.SocketException se = e as System.Net.Sockets.SocketException;
                switch (se.SocketErrorCode)
                {
                case System.Net.Sockets.SocketError.HostNotFound:
                    return(Polish.strNieMoznaOdnalezcSerwera);

                case System.Net.Sockets.SocketError.ConnectionReset:
                    return(Polish.strPolaczenieZostaloUtracone);

                default:
                    return(string.Format(Polish.strInnyBladPolaczenia0, se.SocketErrorCode));
                }
                ;
            }
            return(string.Format(Polish.strInnyBlad0, e.Message));
        }
コード例 #3
0
 public CPanelException(WellKownCpanelProblems aStatus, string f)
     : base(GetStatusDescription(aStatus))
 {
     this.status    = aStatus;
     cPanelFunction = f;
 }