Ejemplo n.º 1
0
        public async Task <Dakka> Get()
        {
            var sourceOne = GetSourceOne();
            var sourceTwo = GetSourceTwo();
            var result    = await sourceOne.Merge(sourceTwo)
                            .RunAggregate(new Dakka(0, string.Empty), MergeDakka, system.Materializer());

            return(result);
        }
        public async Task <ConcurrentSet <LogRptDto> > GenerateReport(LogFile logFile)
        {
            var source         = Source.From(logFile.CheckOuts);
            var getLogRptDto   = Flow.Create <CheckOutDto, bool>().SelectAsyncUnordered(int.MaxValue, checkOut => GetLogRptDto(checkOut, logFile));
            var withoutCheckin = new ConcurrentSet <LogRptDto>();
            await source
            .Via(getLogRptDto)
            .RunWith(Sink.ForEachParallel <LogRptDto>(int.MaxValue, l =>
            {
                if (!string.IsNullOrEmpty(l.ServerHandle))
                {
                    withoutCheckin.TryAdd(l);
                }
            }), actorSystem.Materializer());

            return(withoutCheckin);
        }
        public async Task <LogFile> ParseLogFileEventsAsync(LogFile logFile)
        {
            if (!logFile.Exists())
            {
                return(null);
            }

            var lines = File.ReadAllLines(logFile.Path);

            var startLine = lines.FirstOrDefault(l =>
                                                 l.StartsWith(LogEvents.START.ToString()));

            logFile.ParseStart(startLine);
            logFile.InitializeProgress(lines);
            var t = new List <bool>();
            await Source.From(lines)
            .SelectAsyncUnordered(int.MaxValue, logFile.ParseLine)
            .RunWith(Sink.ForEach <bool>(x => t.Add(x)), actorSystem.Materializer());

            return(logFile);
        }