Example #1
0
        public VAWebRequestDocumentoDownloadEvent(string message, object eventSource, object documentoID, VAWebEventTypeEnum tipo)
            : base(message, eventSource, VAWebEventCodes.DownloadDocumento)
        {
            VARequestInformation = new VAWebRequestInformation();

            if (tipo == VAWebEventTypeEnum.DownloadDocumentoCondivisione)
            {
                VARequestInformation.GuidEntityID = (Guid?)documentoID;
            }
            else
            {
                VARequestInformation.IntEntityID = (int)documentoID;
            }

            VARequestInformation.EventTypeID = tipo;

            if (HttpContext.Current != null)
            {
                VAPrincipal vaPrincipal = HttpContext.Current.User as VAPrincipal;

                if (vaPrincipal != null && vaPrincipal.Utente != null)
                {
                    VARequestInformation.UtenteID   = vaPrincipal.Utente.ID;
                    VARequestInformation.NomeUtente = vaPrincipal.Utente.NomeUtente;
                }

                if (HttpContext.Current.Request.UrlReferrer != null)
                {
                    VARequestInformation.UrlReferrer = HttpContext.Current.Request.UrlReferrer.AbsoluteUri;
                }

                VARequestInformation.UserAgent = HttpContext.Current.Request.UserAgent;
            }
        }
        public VAWebRequestErrorEvent(string message, object eventSource, Exception exception)
            : base(message, eventSource, VAWebEventCodes.ErroreGenerico, GetDetailCode(exception), exception)
        {
            VARequestInformation = new VAWebRequestInformation();

            VARequestInformation.EventTypeID = VAWebEventTypeEnum.Errore;

            if (HttpContext.Current != null)
            {
                VAPrincipal vaPrincipal = HttpContext.Current.User as VAPrincipal;

                if (vaPrincipal != null && vaPrincipal.Utente != null)
                {
                    VARequestInformation.UtenteID   = vaPrincipal.Utente.ID;
                    VARequestInformation.NomeUtente = vaPrincipal.Utente.NomeUtente;
                }

                if (HttpContext.Current.Request.UrlReferrer != null)
                {
                    VARequestInformation.UrlReferrer = HttpContext.Current.Request.UrlReferrer.AbsoluteUri;
                }

                VARequestInformation.UserAgent = HttpContext.Current.Request.UserAgent;
            }
        }
Example #3
0
        private void InsertEvent(WebBaseEvent eventToInsert)
        {
            WebRequestInformation   requestInfo   = null;
            Exception               exception     = null;
            VAWebRequestInformation vaRequestInfo = null;
            DataRow row = _dataTable.NewRow();

            row["EventID"]                = eventToInsert.EventID;
            row["EventTimeUtc"]           = eventToInsert.EventTimeUtc;
            row["EventTime"]              = eventToInsert.EventTime;
            row["EventType"]              = eventToInsert.GetType().ToString();
            row["EventSequence"]          = eventToInsert.EventSequence;
            row["EventOccurrence"]        = eventToInsert.EventOccurrence;
            row["EventCode"]              = eventToInsert.EventCode;
            row["EventDetailCode"]        = eventToInsert.EventDetailCode;
            row["EventMessage"]           = eventToInsert.Message;
            row["MachineName"]            = WebBaseEvent.ApplicationInformation.MachineName;
            row["ApplicationPath"]        = WebBaseEvent.ApplicationInformation.ApplicationPath;
            row["ApplicationVirtualPath"] = WebBaseEvent.ApplicationInformation.ApplicationVirtualPath;

            if (eventToInsert is WebRequestEvent)
            {
                requestInfo = ((WebRequestEvent)eventToInsert).RequestInformation;
            }
            else if (eventToInsert is WebRequestErrorEvent)
            {
                requestInfo = ((WebRequestErrorEvent)eventToInsert).RequestInformation;
            }
            else if (eventToInsert is WebErrorEvent)
            {
                requestInfo = ((WebErrorEvent)eventToInsert).RequestInformation;
            }
            else if (eventToInsert is WebAuditEvent)
            {
                requestInfo = ((WebAuditEvent)eventToInsert).RequestInformation;
            }

            if (eventToInsert is WebBaseErrorEvent)
            {
                exception = ((WebBaseErrorEvent)eventToInsert).ErrorException;
            }

            if (eventToInsert is VAWebRequestErrorEvent)
            {
                vaRequestInfo = ((VAWebRequestErrorEvent)eventToInsert).VARequestInformation;
            }
            else if (eventToInsert is VAWebRequestDocumentoDownloadEvent)
            {
                vaRequestInfo = ((VAWebRequestDocumentoDownloadEvent)eventToInsert).VARequestInformation;
            }

            if (requestInfo != null)
            {
                row["RequestUrl"]      = requestInfo.RequestUrl;
                row["UserHostAddress"] = requestInfo.UserHostAddress;
                row["PrincipalIdentityIsAuthenticated"] = requestInfo.Principal.Identity.IsAuthenticated;

                if (requestInfo.Principal.Identity.IsAuthenticated)
                {
                    row["PrincipalIdentityName"] = requestInfo.Principal.Identity.Name;
                }
            }

            if (exception != null)
            {
                row["ExceptionType"]    = exception.GetType().ToString();
                row["ExceptionMessage"] = exception.Message;
                row["Details"]          = eventToInsert.ToString(true, true);
                row["WebEventTypeID"]   = VAWebEventTypeEnum.Errore;
            }

            if (vaRequestInfo != null)
            {
                if (vaRequestInfo.UtenteID != null)
                {
                    row["UtenteID"]         = vaRequestInfo.UtenteID;
                    row["UtenteNomeUtente"] = vaRequestInfo.NomeUtente;
                }

                if (vaRequestInfo.UrlReferrer != null)
                {
                    row["RequestUrlReferrer"] = vaRequestInfo.UrlReferrer;
                }

                if (vaRequestInfo.UserAgent != null)
                {
                    row["RequestUserAgent"] = vaRequestInfo.UserAgent;
                }

                if (vaRequestInfo.IntEntityID != null)
                {
                    row["IntEntityID"] = vaRequestInfo.IntEntityID;
                }

                if (vaRequestInfo.GuidEntityID != null)
                {
                    row["GuidEntityID"] = vaRequestInfo.GuidEntityID;
                }

                if (vaRequestInfo.EventTypeID != null)
                {
                    row["WebEventTypeID"] = vaRequestInfo.EventTypeID;
                }
            }

            _dataTable.Rows.Add(row);
        }