Наследование: SmartAPIException
Пример #1
0
 internal PageDeletionException(RQLException e)
     : base(e.Server, e.Message, e)
 {
     switch (e.ErrorCode)
     {
         case ErrorCode.RDError2910:
             Error = PageDeletionError.ElementsOfPageStillGetReferenced;
             break;
         case ErrorCode.RDError15805:
             Error = PageDeletionError.NoRightToDeletePage;
             break;
         default:
             Error = PageDeletionError.Unknown;
             break;
     }
 }
Пример #2
0
        internal PageDeletionException(RQLException e) : base(e.Server, e.Message, e)
        {
            switch (e.ErrorCode)
            {
            case ErrorCode.RDError2910:
                Error = PageDeletionError.ElementsOfPageStillGetReferenced;
                break;

            case ErrorCode.RDError15805:
                Error = PageDeletionError.NoRightToDeletePage;
                break;

            default:
                Error = PageDeletionError.Unknown;
                break;
            }
        }
Пример #3
0
        /// <summary>
        ///     Send RQL statement to CMS server and return result.
        /// </summary>
        /// <param name="rqlQuery"> Query to send to CMS server </param>
        /// <param name="debugRQLQuery"> Query to save in log file (this is used to hide passwords in the log files) </param>
        /// <exception cref="RedDotConnectionException">CMS Server not found or couldn't establish connection</exception>
        /// <returns> Result of RQL query </returns>
        private string SendRQLToServer(string rqlQuery, string debugRQLQuery = null)
        {
            try
            {
                LOG.DebugFormat("Sending RQL [{0}]: {1}", ServerLogin.Name, debugRQLQuery ?? rqlQuery);

                object error = "x";
                object resultInfo = "";
                var binding = new BasicHttpBinding();

                var isUsingHttps = ServerLogin.Address.Scheme.ToLowerInvariant() == "https";
                if (isUsingHttps)
                {
                    binding.Security.Mode = BasicHttpSecurityMode.Transport;
                }
                binding.ReaderQuotas.MaxStringContentLength = 2097152*10; //20MB
                binding.ReaderQuotas.MaxArrayLength = 2097152*10; //20mb
                binding.MaxReceivedMessageSize = 2097152*10; //20mb
                binding.ReceiveTimeout = TimeSpan.FromMinutes(10);
                binding.SendTimeout = TimeSpan.FromMinutes(10);

                if (ServerLogin.WindowsAuthentication != null)
                {
                    binding.Security.Transport.ClientCredentialType = HttpClientCredentialType.Ntlm;
                    binding.Security.Mode = isUsingHttps ? BasicHttpSecurityMode.TransportWithMessageCredential : BasicHttpSecurityMode.TransportCredentialOnly;
                }

                var add = new EndpointAddress(CmsServerConnectionUrl);

                try
                {
                    var client = new RqlWebServiceClient(binding, add);
                    if (ServerLogin.WindowsAuthentication != null)
                    {
                        client.ClientCredentials.Windows.ClientCredential = ServerLogin.WindowsAuthentication;
                        //client.ClientCredentials.Windows.AllowNtlm = true;
                        client.ClientCredentials.Windows.AllowedImpersonationLevel =
                            TokenImpersonationLevel.Impersonation;
                    }
                    //var channel = client.ChannelFactory.CreateChannel();
                    //var res = channel.Execute(new ExecuteRequest(rqlQuery, error, resultInfo));
                    //var result = res.Result;

                    string result = client.Execute(rqlQuery, ref error, ref resultInfo);
                    string errorStr = (error ?? "").ToString();
                    if (!string.IsNullOrEmpty(errorStr))
                    {
                        var exception = new RQLException(ServerLogin.Name, errorStr, result);
                        if (exception.ErrorCode == ErrorCode.NoRight || exception.ErrorCode == ErrorCode.RDError110)
                        {
                            throw new MissingPrivilegesException(exception);
                        }
                        throw exception;
                    }
                    LOG.DebugFormat("Received RQL [{0}]: {1}", ServerLogin.Name, result);
                    return result;
                } catch (Exception e)
                {
                    string msg = ExtractMessagesWithInnerExceptions(e);
                    LOG.Error(msg);
                    LOG.Debug(e.StackTrace);
                    throw;
                }
            } catch (EndpointNotFoundException e)
            {
                LOG.ErrorFormat("Server not found: {0}", CmsServerConnectionUrl);
                throw new RedDotConnectionException(RedDotConnectionException.FailureTypes.ServerNotFound,
                                                    string.Format(@"Server ""{0}"" not found", CmsServerConnectionUrl),
                                                    e);
            }
        }
Пример #4
0
 protected RQLException(RQLException rqlException)
     : this(rqlException.Server, rqlException.ErrorMessage, rqlException.Response)
 {
     ErrorCode = rqlException.ErrorCode;
 }
Пример #5
0
 protected RQLException(RQLException rqlException)
     : this(rqlException.Server, rqlException.ErrorMessage, rqlException.Response)
 {
     ErrorCode = rqlException.ErrorCode;
 }