Esempio n. 1
0
        //public int GetSource(LogSources source)
        //{
        //    if (source == LogSources.USER) return 0;

        //    ExternalSystem system;
        //    switch (source)
        //    {
        //        case LogSources.S2EXPORT:
        //            system = ExternalSystems.FirstOrDefault(x => x.Name == "S2");
        //            return system == null ? 0 : system.Id;

        //        case LogSources.S2IMPORT:
        //            system = ExternalSystems.FirstOrDefault(x => x.Name == "S2");
        //            return system == null ? 0 : system.Id;

        //        case LogSources.PSIMPORT:
        //            system = ExternalSystems.FirstOrDefault(x => x.Name == "PeopleSoft");
        //            return system == null ? 0 : system.Id;
        //    }

        //    return (int)source;
        //}

        //public bool GetDirection(LogSources source)
        //{
        //    switch (source)
        //    {
        //        case LogSources.S2EXPORT:
        //            return false;

        //        case LogSources.S2IMPORT:
        //            return true;

        //        case LogSources.PSIMPORT:
        //            return true;

        //        default:
        //            return false;
        //    }
        //}

        //public void Syslog(LogSources src, LogSeverity sev, string message, string details)
        //{
        //    var sourceId = GetSource(src);
        //    var direction = GetDirection(src);

        //    var ent = new LogEntry
        //                       {
        //                           EventDate = DateTime.Now,
        //                           Source = sourceId,
        //                           Severity = (int) sev,
        //                           Message = message,
        //                           Details = details
        //                       };

        //    try
        //    {
        //        LogEntries.InsertOnSubmit(ent);
        //        SubmitChanges();
        //    }
        //    catch (Exception)
        //    {
        //        // Don't choke if we can't log.
        //    }
        //}

        public void Syslog(ExternalSystem system, Severity sev, string message, string details)
        {
            var severity = (int)sev;

            var sourceId = system == null ? 0 : system.Id;

            var ent = new LogEntry
            {
                EventDate = DateTime.Now,
                Source    = sourceId,
                Severity  = severity,
                Message   = message,
                Details   = details
            };

            try
            {
                LogEntries.InsertOnSubmit(ent);
                SubmitChanges();
            }
            catch (Exception ex)
            {
                // Don't choke if we can't log.
                EventLog.WriteEntry("R1SM", string.Format("Error saving log.\n{0}", ex.Message), EventLogEntryType.Error);
            }
        }
Esempio n. 2
0
        public static ExternalSystem ToModel(this RSMDB.ExternalSystem from, ExternalSystem existing = null)
        {
            var entity = existing == null ? new ExternalSystem() : existing;

            entity.Id        = from.Id;
            entity.Name      = from.Name;
            entity.Direction = (RSMDB.ExternalSystemDirection)from.Direction;

            return(entity);
        }
Esempio n. 3
0
 public bool Equals(ExternalSystem other)
 {
     if (ReferenceEquals(null, other))
     {
         return(false);
     }
     if (ReferenceEquals(this, other))
     {
         return(true);
     }
     return(other._Id == _Id && Equals(other._Name, _Name) && other._Direction.Equals(_Direction));
 }
Esempio n. 4
0
        //public enum LogSources
        //{
        //    S2IMPORT, //0 -> 2 *
        //    S2EXPORT, //1 -> 4 *
        //    PSIMPORT, //2 -> 5 *
        //    USER      //3 -> 0 *
        //}

        //public enum LogSeverity
        //{
        //    INFO,
        //    WARN,
        //    ERROR,
        //    DEBUG
        //}

        //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 int CountLogEntriesWithStatus(ExternalSystem system, Severity sev, DateTime since)
        {
            var severity = (int)sev;

            if (system == null)
            {
                return(0);
            }

            return(LogEntries.Count(l => l.Source == system.Id &&
                                    l.EventDate >= since &&
                                    l.Severity == severity));
        }