protected override void SendBuffer(LoggingEvent[] events) { foreach (var evt in events) { try { var assembly = String.Join(",", Assembly.GetExecutingAssembly().FullName.Split(',').Take(2)); var log = new ExceptionLogEntity { DeviceId = 1, RemoteExceptionLogId = 0, Title = evt.RenderedMessage.Substring(0, Math.Min(evt.RenderedMessage.Length, ExceptionLogFields.Title.MaxLength)), Message = evt.ExceptionObject != null?evt.ExceptionObject.Message.Substring(0, Math.Min(evt.ExceptionObject.Message.Length, ExceptionLogFields.Message.MaxLength)) : "", StackTrace = evt.ExceptionObject != null?evt.ExceptionObject.StackTrace.Substring(0, Math.Min(evt.ExceptionObject.StackTrace.Length, ExceptionLogFields.StackTrace.MaxLength)) : "", LogTime = evt.TimeStamp, User = evt.Identity, FormName = evt.LoggerName, MachineName = Environment.MachineName, MachineOS = Environment.OSVersion.VersionString, ApplicationVersion = assembly, CLRVersion = Environment.Version.ToString(), MemoryUsage = Environment.WorkingSet.ToString(CultureInfo.InvariantCulture), ReceivedTime = DateTime.UtcNow }; log.Save(); } catch { // eat it } } }
public V0100.Objects.ExceptionLog Create(V0100.Objects.ExceptionLog exceptionLog) { DeviceEntity device = GetDevice(); ExceptionLogEntity log = new ExceptionLogEntity { DeviceId = device.DeviceId, RemoteExceptionLogId = exceptionLog.RemoteExceptionLogId, Title = exceptionLog.Title, Message = exceptionLog.Message, StackTrace = exceptionLog.StackTrace, LogTime = exceptionLog.LogTime, User = exceptionLog.User, FormName = exceptionLog.FormName, MachineName = exceptionLog.MachineName, MachineOS = exceptionLog.MachineOS, ApplicationVersion = exceptionLog.ApplicationVersion, CLRVersion = exceptionLog.CLRVersion, MemoryUsage = exceptionLog.MemoryUsage, ReceivedTime = DateTime.UtcNow }; log.Save(); exceptionLog.ExceptionLogId = log.ExceptionLogId; exceptionLog.ReceivedTime = log.ReceivedTime; OperationController.Update(); return(exceptionLog); }
public static bool SendExceptionImpl(string deviceUniqueKey, Exception ex, ExceptionAdditionalInfo exInfo) { ExceptionLogEntity ecExceptionLogEntity = new ExceptionLogEntity(); //ecExceptionLogEntity.CustomerId = customerId; ecExceptionLogEntity.DeviceId = KeyToIdHelpers.ConvertDeviceKey(deviceUniqueKey); ecExceptionLogEntity.RemoteExceptionLogId = (long)exInfo.CustomersLogExceptionId; //ecExceptionLogEntity.CustomerExceptionObject = ObjectSerialization.ObjectToByteArray(ex); ecExceptionLogEntity.Title = String.Empty; ecExceptionLogEntity.Message = ex.Message; ecExceptionLogEntity.StackTrace = ex.StackTrace; //ecExceptionLogEntity.CustomerExceptionInnerStackTrace = ex.InnerException.StackTrace; ecExceptionLogEntity.LogTime = exInfo.ExceptionDateTime; ecExceptionLogEntity.User = exInfo.ExceptionUser; ecExceptionLogEntity.FormName = exInfo.ExceptionFormName; ecExceptionLogEntity.MachineName = exInfo.ExceptionMachineName; ecExceptionLogEntity.MachineOS = exInfo.ExceptionMachineOS; ecExceptionLogEntity.ApplicationVersion = exInfo.ExceptionApplicationVersion; ecExceptionLogEntity.CLRVersion = exInfo.ExceptionCLRVersion; ecExceptionLogEntity.MemoryUsage = exInfo.ExceptionMemoryUsage; ecExceptionLogEntity.ReceivedTime = DateTime.Now; ecExceptionLogEntity.Save(); return(true); }