Example #1
0
 public EntryLog(long userNum, EntryLogFKeyType keyType, long Fkey, LogSources logSource)
 {
     UserNum   = userNum;
     FKeyType  = keyType;
     FKey      = Fkey;
     LogSource = logSource;
 }
Example #2
0
        public MainViewModel(IDataService dataService)
        {
            InitializeCommands();

            MainWindowTitle = "EventLook" + (ProcessHelper.IsElevated ? " (Administrator)" : "");
            DataService     = dataService;
            Events          = new ObservableCollection <EventItem>();

            logSourceMgr      = new LogSourceMgr();
            SelectedLogSource = LogSources.FirstOrDefault();

            rangeMgr      = new RangeMgr();
            SelectedRange = Ranges.FirstOrDefault(r => r.DaysFromNow == 3);

            sourceFilter = new Model.SourceFilter();
            levelFilter  = new LevelFilter();
            MsgFilter    = new MessageFilter();
            IdFilter     = new IdFilter();

            filters = new List <FilterBase> {
                sourceFilter, levelFilter, MsgFilter, IdFilter
            };

            progress  = new Progress <ProgressInfo>(ProgressCallback); // Needs to instantiate in UI thread
            stopwatch = new Stopwatch();

            Messenger.Default.Register <ViewCollectionViewSourceMessageToken>(this, Handle_ViewCollectionViewSourceMessageToken);
            Messenger.Default.Register <FileToBeProcessedMessageToken>(this, Handle_FileToBeProcessedMessageToken);
            Messenger.Default.Register <DetailWindowMessageToken>(this, Handle_DetailWindowMessageToken);
        }
 public int CountLogEntriesWithStatus(LogSources source, LogSeverity sev, DateTime since)
 {
     return((from l in LogEntries
             where ((l.Source == (int)source) &&
                    (l.EventDate >= since) &&
                    (l.Severity == (int)sev))
             select l).Count());
 }
        public void Syslog(LogSources src, LogSeverity sev, string message, string details)
        {
            LogEntry ent = new LogEntry
            {
                EventDate = DateTime.Now,
                Source    = (int)src,
                Severity  = (int)sev,
                Message   = message,
                Details   = details
            };

            try
            {
                LogEntries.InsertOnSubmit(ent);
                SubmitChanges();
            }
            catch (Exception)
            {
                // Don't choke if we can't log.
            }
        }
Example #5
0
        public MainViewModel(IDataService dataService)
        {
            InitializeCommands();
            DataService = dataService;
            Events      = new ObservableCollection <EventItem>();

            logSourceMgr      = new LogSourceMgr();
            SelectedLogSource = LogSources.FirstOrDefault();

            rangeMgr      = new RangeMgr();
            SelectedRange = Ranges.FirstOrDefault(r => r.DaysFromNow == 3);

            sourceFilter = new Model.SourceFilter();
            MsgFilter    = new MessageFilter();
            filters      = new List <FilterBase> {
                sourceFilter, MsgFilter
            };

            progress  = new Progress <ProgressInfo>(ProgressCallback); // Needs to instantiate in UI thread
            stopwatch = new Stopwatch();

            Messenger.Default.Register <ViewCollectionViewSourceMessageToken>(this, Handle_ViewCollectionViewSourceMessageToken);
        }
        public void PopulateEvent(Event ev)
        {
            if (MinDate.HasValue || MaxDate.HasValue)
            {
                ev.Date = RandomData.GetDateTime(MinDate ?? DateTime.MinValue, MaxDate ?? DateTime.MaxValue);
            }

            ev.Type = new [] { Event.KnownTypes.Error, Event.KnownTypes.FeatureUsage, Event.KnownTypes.Log, Event.KnownTypes.NotFound }.Random();
            if (ev.Type == Event.KnownTypes.FeatureUsage)
            {
                ev.Source = FeatureNames.Random();
            }
            else if (ev.Type == Event.KnownTypes.NotFound)
            {
                ev.Source = PageNames.Random();
            }
            else if (ev.Type == Event.KnownTypes.Log)
            {
                ev.Source  = LogSources.Random();
                ev.Message = RandomData.GetString();

                string level = LogLevels.Random();
                if (!String.IsNullOrEmpty(level))
                {
                    ev.Data[Event.KnownDataKeys.Level] = level;
                }
            }

            if (RandomData.GetBool(80))
            {
                ev.Geo = RandomData.GetCoordinate();
            }

            if (RandomData.GetBool(20))
            {
                ev.Value = RandomData.GetInt(0, 10000);
            }

            ev.SetUserIdentity(Identities.Random());
            ev.SetVersion(RandomData.GetVersion("2.0", "4.0"));

            ev.AddRequestInfo(new RequestInfo {
                //ClientIpAddress = ClientIpAddresses.Random(),
                Path = PageNames.Random()
            });

            ev.Data.Add(Event.KnownDataKeys.EnvironmentInfo, new EnvironmentInfo {
                IpAddress   = MachineIpAddresses.Random() + ", " + MachineIpAddresses.Random(),
                MachineName = MachineNames.Random()
            });

            for (int i = 0; i < RandomData.GetInt(1, 3); i++)
            {
                string key = RandomData.GetWord();
                while (ev.Data.ContainsKey(key) || key == Event.KnownDataKeys.Error)
                {
                    key = RandomData.GetWord();
                }

                ev.Data.Add(key, RandomData.GetString());
            }

            int tagCount = RandomData.GetInt(1, 3);

            for (int i = 0; i < tagCount; i++)
            {
                string tag = EventTags.Random();
                if (!ev.Tags.Contains(tag))
                {
                    ev.Tags.Add(tag);
                }
            }

            if (ev.Type == Event.KnownTypes.Error)
            {
                if (RandomData.GetBool())
                {
                    // limit error variation so that stacking will occur
                    if (_randomErrors == null)
                    {
                        _randomErrors = new List <Error>(Enumerable.Range(1, 25).Select(i => GenerateError()));
                    }

                    ev.Data[Event.KnownDataKeys.Error] = _randomErrors.Random();
                }
                else
                {
                    // limit error variation so that stacking will occur
                    if (_randomSimpleErrors == null)
                    {
                        _randomSimpleErrors = new List <SimpleError>(Enumerable.Range(1, 25).Select(i => GenerateSimpleError()));
                    }

                    ev.Data[Event.KnownDataKeys.SimpleError] = _randomSimpleErrors.Random();
                }
            }
        }
Example #7
0
        ///<summary>Used when making a security log from a remote server, possibly with multithreaded connections.</summary>
        public static void MakeLogEntryNoCache(Permissions permType, long patnum, string logText, long userNum, LogSources source)
        {
            SecurityLog securityLog = new SecurityLog();

            securityLog.PermType       = permType;
            securityLog.UserNum        = userNum;
            securityLog.LogText        = logText;
            securityLog.CompName       = Environment.MachineName;
            securityLog.PatNum         = patnum;
            securityLog.FKey           = 0;
            securityLog.LogSource      = source;
            securityLog.SecurityLogNum = SecurityLogs.InsertNoCache(securityLog);
            SecurityLogHashes.InsertSecurityLogHashNoCache(securityLog.SecurityLogNum);
        }
Example #8
0
        ///<summary>Takes a foreign key to a table associated with that PermType.  PatNum can be 0.  Returns the created SecurityLog object.  Does not perform an insert.</summary>
        public static SecurityLog MakeLogEntryNoInsert(Permissions permType, long patNum, string logText, long fKey, LogSources logSource = LogSources.None
                                                       , long defNum = 0, long defNumError = 0, DateTime DateTPrevious = default(DateTime))
        {
            //No need to check RemotingRole; no call to db.
            SecurityLog securityLog = new SecurityLog();

            securityLog.PermType      = permType;
            securityLog.UserNum       = Security.CurUser.UserNum;
            securityLog.LogText       = logText;    //"From: "+Environment.MachineName+" - "+logText;
            securityLog.CompName      = Environment.MachineName;
            securityLog.PatNum        = patNum;
            securityLog.FKey          = fKey;
            securityLog.LogSource     = logSource;
            securityLog.DefNum        = defNum;
            securityLog.DefNumError   = defNumError;
            securityLog.DateTPrevious = DateTPrevious;
            return(securityLog);
        }
Example #9
0
        ///<summary>Takes a foreign key to a table associated with that PermType.  PatNum can be 0.</summary>
        public static void MakeLogEntry(Permissions permType, long patNum, string logText, long fKey, LogSources logSource, long defNum, long defNumError,
                                        DateTime DateTPrevious)
        {
            //No need to check RemotingRole; no call to db.
            SecurityLog securityLog = MakeLogEntryNoInsert(permType, patNum, logText, fKey, logSource, defNum, defNumError, DateTPrevious);

            MakeLogEntry(securityLog);
        }
Example #10
0
 ///<summary>Takes a foreign key to a table associated with that PermType.  PatNum can be 0.</summary>
 public static void MakeLogEntry(Permissions permType, long patNum, string logText, long fKey, LogSources logSource, DateTime DateTPrevious)
 {
     MakeLogEntry(permType, patNum, logText, fKey, logSource, 0, 0, DateTPrevious);
 }
Example #11
0
 ///<summary>Used when the security log needs to be identified by a particular source.  PatNum can be 0.</summary>
 public static void MakeLogEntry(Permissions permType, long patNum, string logText, LogSources logSource)
 {
     //No need to check RemotingRole; no call to db.
     MakeLogEntry(permType, patNum, logText, 0, logSource, DateTime.MinValue);
 }
Example #12
0
		///<summary>Takes a foreign key to a table associated with that PermType.  PatNum can be 0.</summary>
		public static void MakeLogEntry(Permissions permType,long patNum,string logText,long fKey,LogSources logSource) {
			//No need to check RemotingRole; no call to db.
			SecurityLog securityLog=new SecurityLog();
			securityLog.PermType=permType;
			if(Security.CurUser!=null) { //if this is generated by Patient Portal web service then we won't have a CurUser set
				securityLog.UserNum=Security.CurUser.UserNum;
			}
			securityLog.LogText=logText;//"From: "+Environment.MachineName+" - "+logText;
			securityLog.CompName=Environment.MachineName;
			securityLog.PatNum=patNum;
			securityLog.FKey=fKey;
			securityLog.LogSource=logSource;
			securityLog.SecurityLogNum=SecurityLogs.Insert(securityLog);
			//Create a hash of the security log.
			SecurityLogHashes.InsertSecurityLogHash(securityLog.SecurityLogNum);//uses db date/time
		}
Example #13
0
		///<summary>Used when the security log needs to be identified by a particular source.  PatNum can be 0.</summary>
		public static void MakeLogEntry(Permissions permType,long patNum,string logText,LogSources logSource) {
			//No need to check RemotingRole; no call to db.
			MakeLogEntry(permType,patNum,logText,0,logSource);
		}
Example #14
0
        private void RedirectTapLog(string lines, bool IsStandardError)
        {
            foreach (var line in lines.Split('\n'))
            {
                var    message = line;
                string split   = " : ";

                var logParts = line.Split(new string[] { split }, StringSplitOptions.None);

                if (logParts.Length < 4)
                {
                    if (IsStandardError)
                    {
                        log.Error(message);
                    }
                    else
                    {
                        log.Info(message);
                    }
                    continue;
                }

                var sourceName = logParts[1].Trim();
                var logType    = logParts[2].Trim();

                var idx = 0;

                for (int i = 0; i < 3; i++)
                {
                    idx = message.IndexOf(split, idx, StringComparison.Ordinal) + split.Length;
                }

                message = message.Substring(idx);

                TraceSource source;
                if (LogSources.ContainsKey(sourceName))
                {
                    source = LogSources[sourceName];
                }
                else
                {
                    source = OpenTap.Log.CreateSource(sourceName);
                    LogSources[sourceName] = source;
                }

                switch (logType)
                {
                case "Information":
                    source.Info(message);
                    break;

                case "Error":
                    source.Error(message);
                    break;

                case "Warning":
                    source.Warning(message);
                    break;

                default:
                    source.Debug(message);
                    break;
                }
            }
        }
Example #15
0
        private static void SendEvent(bool writeToConsole = true)
        {
            var ev = new Event();

            if (_dateSpans[_dateSpanIndex] != TimeSpan.Zero)
            {
                ev.Date = RandomHelper.GetDateTime(DateTime.Now.Subtract(_dateSpans[_dateSpanIndex]), DateTime.Now);
            }

            ev.Type = EventTypes.Random();
            if (ev.Type == Event.KnownTypes.FeatureUsage)
            {
                ev.Source = FeatureNames.Random();
            }
            else if (ev.Type == Event.KnownTypes.NotFound)
            {
                ev.Source = PageNames.Random();
            }
            else if (ev.Type == Event.KnownTypes.Log)
            {
                ev.Source  = LogSources.Random();
                ev.Message = RandomHelper.GetPronouncableString(RandomHelper.GetRange(5, 15));
            }

            ev.SetUserIdentity(Identities.Random());

            for (int i = 0; i < RandomHelper.GetRange(1, 5); i++)
            {
                string key = RandomHelper.GetPronouncableString(RandomHelper.GetRange(5, 10));
                while (ev.Data.ContainsKey(key) || key == Event.KnownDataKeys.Error)
                {
                    key = RandomHelper.GetPronouncableString(RandomHelper.GetRange(5, 15));
                }

                ev.Data.Add(key, RandomHelper.GetPronouncableString(RandomHelper.GetRange(5, 25)));
            }

            int tagCount = RandomHelper.GetRange(1, 3);

            for (int i = 0; i < tagCount; i++)
            {
                string tag = EventTags.Random();
                if (!ev.Tags.Contains(tag))
                {
                    ev.Tags.Add(tag);
                }
            }

            if (ev.Type == Event.KnownTypes.Error)
            {
                // limit error variation so that stacking will occur
                if (_randomErrors == null)
                {
                    _randomErrors = new List <Error>(Enumerable.Range(1, 25).Select(i => GenerateError()));
                }

                ev.Data[Event.KnownDataKeys.Error] = _randomErrors.Random();
            }

            // use server settings to see if we should include this data
            if (ExceptionlessClient.Default.Configuration.Settings.GetBoolean("IncludeConditionalData", true))
            {
                ev.AddObject(new { Total = 32.34, ItemCount = 2, Email = "*****@*****.**" }, "Conditional Data");
            }

            //ev.AddRecentTraceLogEntries();

            ExceptionlessClient.Default.SubmitEvent(ev);

            if (writeToConsole)
            {
                Console.SetCursorPosition(0, OPTIONS_MENU_LINE_COUNT + 2);
                Console.WriteLine("Sent 1 event.");
                Trace.WriteLine("Sent 1 event.");

                ClearNonOptionsLines();
            }
        }