public virtual Event LogErrorInDatabase(Exception ex)
        {
            HttpContext context = HttpContext.Current;
            if (context != null)
            {
                using (dbContext = new DataManager(false).CreateDataContext<ExceptionNotifierDataContext>())
                {

                    //
                    // Create an event
                    //
                    eventEntity = new InfoControl.Web.Auditing.Event();

                    eventEntity.ApplicationId = Application.Current.ApplicationId;
                    eventEntity.CurrentDate = DateTime.Now;
                    eventEntity.ExceptionCode = ex.GetHashCode().ToString();
                    eventEntity.Message = GetTextErrorLog(ex);
                    eventEntity.Name = ex.GetType().ToString();
                    eventEntity.Path = context.Request.FilePath;

                    eventEntity.RefererUrl = "";
                    if (context.Request.UrlReferrer != null)
                        eventEntity.RefererUrl = context.Request.UrlReferrer.AbsolutePath;

                    eventEntity.Source = ex.Source;
                    eventEntity.StackTrace = ex.StackTrace;
                    eventEntity.TargetSite = ex.TargetSite.Name;
                    eventEntity.EventType = Convert.ToInt32(EventType.Error);

                    if (context.User != null)
                        if (context.User is AccessControlPrincipal)
                            if ((context.User as AccessControlPrincipal).Identity.UserId > 0)
                                eventEntity.UserId = (context.User as AccessControlPrincipal).Identity.UserId;



                    //  eventEntity.StackTrace += ex.HelpLink;

                    dbContext.Events.InsertOnSubmit(eventEntity);
                    dbContext.SubmitChanges();
                }
            }

            return eventEntity;
        }
 partial void UpdateEvent(Event instance);
 partial void DeleteEvent(Event instance);
 partial void InsertEvent(Event instance);