Example #1
0
        public override void render(StreamWriter sw)
        {
            //縮排階層
            var identLevel = LogLevel > 1 ? LogLevel - 1 : 0;

            if (identLevel == 0)
            {
                sw.WriteLine("--執行緒{1} 日期 {0}", LogDate.ToString("yyyy/MM/dd HH:mm:ss.fff", CultureInfo.InvariantCulture), ThreadCode);
                sw.Write(LogContent);
                sw.WriteLine();
            }
            else
            {
                var sb = new StringBuilder();
                for (var i = 0; i < identLevel; i++)
                {
                    sb.Append("\t");
                }
                var tabstr = sb.ToString();
                sb.Length = 0;
                sb.AppendLine("--" + "".PadLeft(identLevel, '>'));
                sb.AppendFormat("--執行緒{1} 日期 {0}", LogDate.ToString("yyyy/MM/dd HH:mm:ss.fff", CultureInfo.InvariantCulture), ThreadCode);
                sb.AppendLine();
                sb.Append(LogContent);
                sb.AppendLine();
                var lines = sb.ToString().Replace("\r\n", "\n").Split('\n');
                sb.Length = 0;
                lines.forEach(x => { sb.Append(tabstr); sb.Append(x); sb.AppendLine(); });
                sw.Write(sb.ToString());
            }
        }
Example #2
0
 public ImapDetectorObservation ToObservation()
 {
     return(new ImapDetectorObservation()
     {
         IP = ClientIp,
         SessionID = SessionID,
         Success = false,
         User = User,
         UTCTimestamp = LogDate.ToUniversalTime()
     });
 }
Example #3
0
        public AttendanceStatus CalculateStatus(AttendanceLog lastLog)
        {
            if (lastLog == null)
            {
                return(AttendanceStatus.CheckIn);
            }

            var diff       = LogDate.Subtract(lastLog.LogDate);
            var totalHours = Math.Round(diff.TotalHours, 2);

            if (totalHours - GlobalConfig.MaxWorkingHours >= 0.00)
            {
                // if new log date is more than 16 hours after last log date.
                // system think it is one check in.
                return(AttendanceStatus.CheckIn);
            }

            if (GlobalConfig.MaxWorkingHours - totalHours > 0.00 && totalHours - GlobalConfig.MinWorkingHours >= 0.00)
            {
                if (lastLog.LogStatus == AttendanceStatus.CheckIn)
                {
                    return(AttendanceStatus.CheckOut);
                }

                if (lastLog.LogStatus == AttendanceStatus.CheckOut)
                {
                    return(AttendanceStatus.CheckIn);
                }
            }

            if (GlobalConfig.MinWorkingHours - totalHours > 0.00)
            {
                // time range is less than 30 minutes, system think it is a duplicated attendance log.
                if (lastLog.LogStatus == AttendanceStatus.CheckIn)
                {
                    return(AttendanceStatus.CheckIn);
                }

                if (lastLog.LogStatus == AttendanceStatus.CheckOut)
                {
                    return(AttendanceStatus.CheckOut);
                }
            }

            throw new NotSupportedException("Unknown attendance status.");
        }
Example #4
0
        public AttendanceStatus CalculateStatus(AttendanceLog lastLog)
        {
            if (lastLog == null)
            {
                return(AttendanceStatus.CheckIn);
            }

            var diff = LogDate.Subtract(lastLog.LogDate);

            if (diff.TotalHours >= 16)
            {
                // if new log date is more than 16 hours after last log date.
                // system think it is one check in.
                return(AttendanceStatus.CheckIn);
            }

            if (diff.TotalHours < 16 && diff.TotalHours > 0.5)
            {
                if (lastLog.LogStatus == AttendanceStatus.CheckIn)
                {
                    return(AttendanceStatus.CheckOut);
                }

                if (lastLog.LogStatus == AttendanceStatus.CheckOut)
                {
                    return(AttendanceStatus.CheckIn);
                }
            }

            if (diff.TotalHours < 0.5)
            {
                // time range is less than 30 minutes, system think it is a duplicated attendance log.
                if (lastLog.LogStatus == AttendanceStatus.CheckIn)
                {
                    return(AttendanceStatus.CheckIn);
                }

                if (lastLog.LogStatus == AttendanceStatus.CheckOut)
                {
                    return(AttendanceStatus.CheckOut);
                }
            }

            throw new NotSupportedException("Unknown attendance status.");
        }
 public string PrintLong()
 {
     return(String.Format("{0} {1}{2} - {3}",
                          PersianLogType,
                          Title,
                          (Description != "" ? ": " + Description : ""),
                          PublicUtilities.ConvertDateTimeToJalali(LogDate) + " " + LogDate.ToString("HH:mm:ss")));
 }