private Task <LogRptDto> GetLogRptDto(CheckOutDto checkOut, LogFile logFile) { return(Task.Run(() => { //logFile.ProgressInt = 100d / logFile.CheckOuts.Count; var logRptDto = new LogRptDto { Product = checkOut.Product, Version = checkOut.Version, UserName = checkOut.User, HostName = checkOut.Host, ServerHandle = checkOut.ServerHandle, InstalledCount = GetProductInstalledLicCount(checkOut.Product, logFile.Products), InUse = checkOut.CurrentInUse, OutTime = checkOut.TimeStamp, InTime = CheckInTimeProcessingService.GetCheckInTime(checkOut, logFile.CheckIns), RequestTime = RequestTimeProcessingService.GetStrRequestTime(checkOut, logFile.Denys, logFile.CheckOuts) }; if (logRptDto.InTime > DateTime.MinValue) { report.TryAdd(logRptDto); return new LogRptDto(); } else { return logRptDto; } })); }
private bool SetCheckInTime(DateTime InTime, LogRptDto logRptDto) { if (InTime != default(DateTime)) { logRptDto.InTime = InTime; report.TryAdd(logRptDto); return(true); } return(false); }
public Task <Tuple <bool, LogRptDto> > GetCheckInforInUseOuts(LogRptDto logRptDto, IEnumerable <LogFile> logFiles) { IOrderedEnumerable <LogFile> logFilesToCheck = from l in logFiles where l.EndEvent.TimeStamp >= logRptDto.OutTime orderby l.StartEvent.TimeStamp select l; if (logFilesToCheck.Any()) { var firstLogFileWithShutdown = (from l in logFiles where l.Shutdowns.Any(x => x.TimeStamp >= logRptDto.OutTime) orderby l.StartEvent.TimeStamp select l).FirstOrDefault(); if (firstLogFileWithShutdown != null) { logFilesToCheck = from l in logFilesToCheck where l.StartEvent.TimeStamp <= firstLogFileWithShutdown.StartEvent.TimeStamp orderby l.StartEvent.TimeStamp select l; if (logFilesToCheck.Any()) { foreach (var logFile in logFilesToCheck) { var InTime = CheckInTimeProcessingService.GetCheckInTime(logRptDto, logFile); if (SetCheckInTime(InTime, logRptDto)) { return(Task.Run(() => Tuple.Create(true, logRptDto))); } } var firstShutdown = firstLogFileWithShutdown.Shutdowns.OrderBy(x => x.TimeStamp) .FirstOrDefault(x => x.TimeStamp > logRptDto.OutTime); if (SetCheckInTime(firstShutdown.TimeStamp, logRptDto)) { return(Task.Run(() => Tuple.Create(true, logRptDto))); } } } else { foreach (var logFile in logFilesToCheck) { var InTime = CheckInTimeProcessingService.GetCheckInTime(logRptDto, logFile); if (SetCheckInTime(InTime, logRptDto)) { return(Task.Run(() => Tuple.Create(true, logRptDto))); } } } } return(Task.Run(() => Tuple.Create(false, logRptDto))); }
public static DateTime GetCheckInTime(LogRptDto checkOutDto, LogFile logFile) { if (logFile.CheckIns.Count > 0) { var checkIn = logFile.CheckIns.FirstOrDefault(x => x.ServerHandle == checkOutDto.ServerHandle && x.Product == checkOutDto.Product && x.User == checkOutDto.UserName && x.TimeStamp >= checkOutDto.OutTime && x.Host == checkOutDto.HostName); if (checkIn.TimeStamp != default(DateTime)) { return(checkIn.TimeStamp); } } return(default(DateTime)); }