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; } })); }
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))); }