示例#1
0
        /// <summary>
        /// For args.Limit see http://data-connector-api.readthedocs.org/en/latest/before-you-start.html#limit
        /// For args.SearchCriteria see http://data-connector-api.readthedocs.org/en/latest/before-you-start.html#date-range
        /// </summary>
        /// <param name="args">See http://data-connector-api.readthedocs.org/en/latest/before-you-start.html for guidance</param>
        /// <param name="properties"></param>
        /// <returns></returns>
        public async Task <IEnumerable <MediaUser> > GetMediaForUsersAsync(MediaForUsersArgs args, DataConnectorProperties properties)
        {
            /*
             * Note for Integration Engineer:
             *
             * It is crucial that you incorporate and honour the args.Limit property. Please let Coach dictate how many recordings it needs.
             *  - see http://data-connector-api.readthedocs.org/en/latest/before-you-start.html#limit
             * It is also crucial you implement a filter on a date range.  Without a date filter you will always return the same set of recordings
             *  - see http://data-connector-api.readthedocs.org/en/latest/before-you-start.html#date-rang
             */

            var result = new List <MediaUser>();
            MediaForUserArgs userArgs = CreateMediaForUserArgs(args);

            foreach (var userId in args.UserIds)
            {
                IEnumerable <Media> media = await this.GetMediaForUserAsync(userId, userArgs, properties);

                IEnumerable <MediaUser> mediaUsers = media.Select(x => new MediaUser {
                    MediaId = x.Id, RecorderUserId = x.RecorderUserId
                }).ToList();
                result.AddRange(mediaUsers);
                media.ToList().Clear();
                mediaUsers.ToList().Clear();
            }

            return(result);
        }
示例#2
0
 private static MediaForUserArgs CreateMediaForUserArgs(MediaForUsersArgs args)
 {
     return(new MediaForUserArgs
     {
         Limit = args.Limit,
         SearchCriteria = args.SearchCriteria,
         TimeZone = args.TimeZone
     });
 }
        public async Task<IEnumerable<MediaUser>> PostAsync(MediaForUsersArgs args)
        {
            var client = NinjectWebCommon.Kernel.Get<IRecorderApiFacade>();
            try
            {
                return await client.GetMediaForUsersAsync(args, this.GetDataConnectorProperties());
            }
            catch (Exception ex)
            {
                Trace.TraceError("connector : [{0}]", ex.Message);
            }

            return await Task.FromResult(new List<MediaUser>());
        }
示例#4
0
        public async Task <IEnumerable <MediaUser> > PostAsync(MediaForUsersArgs args)
        {
            var client = NinjectWebCommon.Kernel.Get <IRecorderApiFacade>();

            try
            {
                return(await client.GetMediaForUsersAsync(args, this.GetDataConnectorProperties()));
            }
            catch (Exception ex)
            {
                Trace.TraceError("connector : [{0}]", ex.Message);
            }

            return(await Task.FromResult(new List <MediaUser>()));
        }
示例#5
0
 private static MediaForUserArgs CreateMediaForUserArgs(MediaForUsersArgs args)
 {
     return new MediaForUserArgs
     {
         Limit = args.Limit,
         SearchCriteria = args.SearchCriteria,
         TimeZone = args.TimeZone
     };
 }
示例#6
0
        /// <summary>
        /// For args.Limit see http://data-connector-api.readthedocs.org/en/latest/before-you-start.html#limit
        /// For args.SearchCriteria see http://data-connector-api.readthedocs.org/en/latest/before-you-start.html#date-range
        /// </summary>
        /// <param name="args">See http://data-connector-api.readthedocs.org/en/latest/before-you-start.html for guidance</param>
        /// <param name="properties"></param>
        /// <returns></returns>
        public async Task<IEnumerable<MediaUser>> GetMediaForUsersAsync(MediaForUsersArgs args, DataConnectorProperties properties)
        {
            /*
             * Note for Integration Engineer:
             * 
             * It is crucial that you incorporate and honour the args.Limit property. Please let Coach dictate how many recordings it needs.
             *  - see http://data-connector-api.readthedocs.org/en/latest/before-you-start.html#limit
             * It is also crucial you implement a filter on a date range.  Without a date filter you will always return the same set of recordings
             *  - see http://data-connector-api.readthedocs.org/en/latest/before-you-start.html#date-rang
             */

            var result = new List<MediaUser>();
            MediaForUserArgs userArgs = CreateMediaForUserArgs(args);

            foreach (var userId in args.UserIds)
            {
                IEnumerable<Media> media = await this.GetMediaForUserAsync(userId, userArgs, properties);
                IEnumerable<MediaUser> mediaUsers = media.Select(x => new MediaUser { MediaId = x.Id, RecorderUserId = x.RecorderUserId }).ToList();
                result.AddRange(mediaUsers);
                media.ToList().Clear();
                mediaUsers.ToList().Clear();
            }

            return result;
        }