Пример #1
0
        /// <summary>
        /// Equality is based on the id field.
        /// </summary>
        /// <param name="obj">The object to compare with this one.</param>
        /// <returns>true if the given object is logically equal to this one.</returns>
        public override bool Equals(object obj)
        {
            LogListener other = obj as LogListener;

            if (other == null)
            {
                return(false);
            }

            return(this.Id == other.Id);
        }
Пример #2
0
        /// <summary>
        /// Delete the given log parameters.
        /// </summary>
        /// <param name="logListener">The log listener to delete.</param>
        public void DeleteLogListener(LogListener logListener)
        {
            if (logListener == null)
            {
                throw new ArgumentNullException("logParameters");
            }

            if (String.IsNullOrWhiteSpace(logListener.Id))
            {
                return;
            }

            SalesForceAPI.Tooling.deleteResponse response = _client.ToolingClient.delete(new SalesForceAPI.Tooling.deleteRequest(
                                                                                             new SalesForceAPI.Tooling.SessionHeader()
            {
                sessionId = _client.SessionId
            },
                                                                                             new string[] { logListener.Id }));

            if (response != null && response.result != null && response.result.Length == 1)
            {
                if (!response.result[0].success)
                {
                    StringBuilder sb = new StringBuilder();
                    if (response.result[0].errors != null)
                    {
                        foreach (SalesForceAPI.Tooling.Error err in response.result[0].errors)
                        {
                            sb.AppendLine(err.message);
                        }
                    }

                    throw new Exception("Couldn't delete checkpoint: \r\n" + sb.ToString());
                }
            }
            else
            {
                throw new Exception("Couldn't delete checkpoint: Invalid response received.");
            }
        }
Пример #3
0
        /// <summary>
        /// Update the given log listener.
        /// </summary>
        /// <param name="logListener">The log listener to update.</param>
        public void UpdateLogListener(LogListener logListener)
        {
            if (logListener == null)
            {
                throw new ArgumentNullException("logParameters");
            }

            SalesForceAPI.Tooling.updateResponse response = _client.ToolingClient.update(new SalesForceAPI.Tooling.updateRequest(
                                                                                             new SalesForceAPI.Tooling.SessionHeader()
            {
                sessionId = _client.SessionId
            },
                                                                                             new SalesForceAPI.Tooling.sObject[]
            {
                logListener.ToTraceFlag()
            }));

            if (response != null && response.result != null && response.result.Length == 1)
            {
                if (!response.result[0].success)
                {
                    StringBuilder sb = new StringBuilder();
                    if (response.result[0].errors != null)
                    {
                        foreach (SalesForceAPI.Tooling.Error err in response.result[0].errors)
                        {
                            sb.AppendLine(err.message);
                        }
                    }

                    throw new Exception("Couldn't update log parameters: \r\n" + sb.ToString());
                }
            }
            else
            {
                throw new Exception("Couldn't update log parameters: Invalid response received.");
            }
        }