Пример #1
0
        public override Exception GetMappedException(Exception ex)
        {
            Type type = ex.GetType();

            if (type.FullName != "Sybase.Data.AseClient.AseException")
            {
                return(base.GetMappedException(ex));
            }

            PropertyInfo property = type.GetProperty("Errors");
            object       value    = property.GetValue(ex, null);

            if (value == null)
            {
                return(base.GetMappedException(ex));
            }

            IEnumerable errors     = (IEnumerable)value;
            IEnumerator enumerator = errors.GetEnumerator();

            if (!enumerator.MoveNext())
            {
                return(base.GetMappedException(ex));
            }

            object                 error           = enumerator.Current;
            SybaseMessage          sybaseError     = new SybaseMessage(error);
            SybaseWrappedException sybaseException = new SybaseWrappedException(sybaseError, ex);

            return(sybaseException);
        }
Пример #2
0
        public void OnAseConnectionInfoEvent(object sender, EventArgs e)
        {
            Type         eType    = e.GetType();
            PropertyInfo property = eType.GetProperty("Message", typeof(string));
            object       value    = property.GetValue(e, null);
            string       message  = (string)value;

            property = eType.GetProperty("Errors");
            value    = property.GetValue(e, null);
            IEnumerable errors = (IEnumerable)value;

            if (errors == null)
            {
                SybaseMessageEventArgs eventArgs = new SybaseMessageEventArgs(message);
                OnDbMessage(eventArgs);
            }
            else
            {
                // Sybase sometimes repeats the same message several time.
                // To avoid message spamming we emit each equal message one time.
                object prevError   = null;
                string prevMessage = null;
                foreach (object error in errors)
                {
                    if (error == null)
                    {
                        continue;
                    }

                    if (Object.Equals(prevError, error))
                    {
                        continue;
                    }
                    prevError = error;


                    SybaseMessage infoMessage = new SybaseMessage(error);
                    if (Object.Equals(prevMessage, infoMessage.Message))
                    {
                        continue;
                    }
                    prevMessage = infoMessage.Message;

                    SybaseMessageEventArgs eventArgs = new SybaseMessageEventArgs(infoMessage);
                    OnDbMessage(eventArgs);
                }
            }
        }
Пример #3
0
 private static TraceLevel GetSeverity(SybaseMessage message)
 {
     return(TraceLevel.Info);
 }
Пример #4
0
 public SybaseWrappedException(SybaseMessage sybaseError, Exception innerException)
     : base(sybaseError, innerException)
 {
 }
Пример #5
0
 public SybaseMessageEventArgs(SybaseMessage message)
     : base(GetSeverity(message), message.Server, message.Catalog, message.Procedure, message.LineNumber, message.Message)
 {
 }