/// <summary> /// Crea una entrada en el visor de eventos /// </summary> /// <param name="msg"></param> /// <param name="eventType"></param> public static void LogWinEvent(string msg, Fwk.Logging.EventType eventType) { Fwk.Logging.Event ev = new Fwk.Logging.Event(); ev.LogType = eventType; ev.Source = ""; ev.Message.Text = msg; try { if (!logOnWindowsEvent) { StaticLogger.Log(TargetType.WindowsEvent, ev, string.Empty, string.Empty); } Audit(msg); } catch (System.Security.SecurityException) { logOnWindowsEvent = false; } }
/// <summary> /// Almacena informacion de auditoria.- /// Llama a StaticLogger y carga el log auditando los datos del Request de entrada /// </summary> /// <param name="pRequest">Request</param> /// <param name="wResult">Response</param> /// <param name="logType">Audit default</param> public static void LogSuccessfulExecution(IServiceContract pRequest, IServiceContract wResult, Fwk.Logging.EventType logType = Fwk.Logging.EventType.Audit) { fwk_ServiceAudit audit = new fwk_ServiceAudit(); audit.LogTime = System.DateTime.Now; audit.ServiceName = pRequest.ServiceName; audit.Send_Time = pRequest.ContextInformation.HostTime; if (Fwk.HelperFunctions.DateFunctions.IsSqlDateTimeOutOverflow(wResult.ContextInformation.HostTime) == false) { audit.Resived_Time = wResult.ContextInformation.HostTime; } else { audit.Resived_Time = wResult.ContextInformation.HostTime = DateTime.Now; } audit.Send_UserId = pRequest.ContextInformation.UserId; audit.Send_Machine = pRequest.ContextInformation.HostName; audit.Dispatcher_Instance_Name = FacadeHelper.ServiceDispatcherConfig.InstanseName; audit.ApplicationId = pRequest.ContextInformation.AppId; try { audit.RequetsText = HelperFunctions.SerializationFunctions.SerializeObjectToJson_Newtonsoft(pRequest); audit.ResponseText = HelperFunctions.SerializationFunctions.SerializeObjectToJson_Newtonsoft(wResult.Error); } catch { //Si existe error al serializar json almacena el xml audit.RequetsText = pRequest.GetXml(); audit.ResponseText = wResult.Error.GetXml(); } audit.Logtype = Enum.GetName(typeof(Fwk.Logging.EventType), logType); try { using (FwkDatacontext context = new FwkDatacontext(System.Configuration.ConfigurationManager.ConnectionStrings[ConfigurationsHelper.ServiceDispatcherConnection].ConnectionString)) { context.fwk_ServiceAudit.InsertOnSubmit(audit); context.SubmitChanges(); } } catch (Exception ex) { TechnicalException te = new TechnicalException("No se pudo insertar la auditoria de la ejecucion de un servicio.- " + ex.Message.ToString(), ex); te.ErrorId = "7010"; Fwk.Exceptions.ExceptionHelper.SetTechnicalException(te, typeof(Audit)); LogDispatcherError(te); LogSuccessfulExecution_Old(pRequest, wResult); } }