Пример #1
0
        public override IEnumerable <IRecordingDto> GetRecordings(IRecordingDtoBuilder dtoBuilder, string scoId, string accountUrl, TimeZoneInfo timeZone)
        {
            var result            = new List <IRecordingDto>();
            var seminarRecordings = AcProxy.GetRecordingsList(scoId);
            var seminarSessions   = _seminarService.GetSeminarSessions(scoId, AcProxy);

            if (MaxDegreeOfParallelism > 1)
            {
                object localLockObject = new object();

                Parallel.ForEach(
                    seminarSessions,
                    new ParallelOptions {
                    MaxDegreeOfParallelism = 20,
                },
                    () => { return(new List <IRecordingDto>()); },
                    (seminarSession, state, localList) =>
                {
                    ProcessSession(AcProxy,
                                   scoId,
                                   seminarSession,
                                   dtoBuilder,
                                   accountUrl,
                                   timeZone,
                                   localList);

                    return(localList);
                },
                    (finalResult) => { lock (localLockObject) result.AddRange(finalResult); }
                    );
            }
            else
            {
                foreach (var seminarSession in seminarSessions)
                {
                    ProcessSession(AcProxy,
                                   scoId,
                                   seminarSession,
                                   dtoBuilder,
                                   accountUrl,
                                   timeZone,
                                   result);
                }
            }

            var recordingsWithoutSession = seminarRecordings.Values
                                           .Where(x => x.Icon != "mp4-archive")
                                           .Where(x => result.All(r => !r.Id.Equals(x.ScoId)))
                                           .Select(x =>
            {
                var dto = dtoBuilder.Build(x, accountUrl, timeZone);
                return(dto);
            })
                                           .ToList();

            result.AddRange(recordingsWithoutSession);

            return(result);
        }
Пример #2
0
        public override IEnumerable <IRecordingDto> GetRecordings(IRecordingDtoBuilder dtoBuilder, string scoId, string accountUrl, TimeZoneInfo timeZone)
        {
            var result        = new List <IRecordingDto>();
            var apiRecordings = AcProxy.GetRecordingsList(scoId, 0, int.MaxValue, "date-begin", SortOrder.Descending, excludeMp4: true);

            foreach (var recording in apiRecordings.Values)
            {
                var dto = dtoBuilder.Build(recording, accountUrl, timeZone);
                result.Add(dto);
            }

            return(result);
        }